getDevice method
Given a device key, returns information about a remembered device for the current user. For more information about device authentication, see Working with user devices in your user pool.
Authorize this action with a signed-in user's access token. It must
include the scope aws.cognito.signin.user.admin.
May throw ForbiddenException.
May throw InternalErrorException.
May throw InvalidParameterException.
May throw InvalidUserPoolConfigurationException.
May throw NotAuthorizedException.
May throw OperationNotEnabledException.
May throw PasswordResetRequiredException.
May throw ResourceNotFoundException.
May throw TooManyRequestsException.
May throw UserNotConfirmedException.
May throw UserNotFoundException.
Parameter deviceKey :
The key of the device that you want to get information about.
Parameter accessToken :
A valid access token that Amazon Cognito issued to the currently signed-in
user. Must include a scope claim for
aws.cognito.signin.user.admin.
Implementation
Future<GetDeviceResponse> getDevice({
required String deviceKey,
String? accessToken,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSCognitoIdentityProviderService.GetDevice'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
signed: false,
// TODO queryParams
headers: headers,
payload: {
'DeviceKey': deviceKey,
if (accessToken != null) 'AccessToken': accessToken,
},
);
return GetDeviceResponse.fromJson(jsonResponse.body);
}