changePassword method
Changes the password for the currently signed-in user.
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 InvalidPasswordException.
May throw LimitExceededException.
May throw NotAuthorizedException.
May throw OperationNotEnabledException.
May throw PasswordHistoryPolicyViolationException.
May throw PasswordResetRequiredException.
May throw ResourceNotFoundException.
May throw TooManyRequestsException.
May throw UserNotConfirmedException.
May throw UserNotFoundException.
Parameter accessToken :
A valid access token that Amazon Cognito issued to the user whose password
you want to change.
Parameter proposedPassword :
A new password that you prompted the user to enter in your application.
Parameter previousPassword :
The user's previous password. Required if the user has a password. If the
user has no password and only signs in with passwordless authentication
options, you can omit this parameter.
Implementation
Future<void> changePassword({
required String accessToken,
required String proposedPassword,
String? previousPassword,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'AWSCognitoIdentityProviderService.ChangePassword'
};
await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
signed: false,
// TODO queryParams
headers: headers,
payload: {
'AccessToken': accessToken,
'ProposedPassword': proposedPassword,
if (previousPassword != null) 'PreviousPassword': previousPassword,
},
);
}