API Reference
autoSignIn
Signs a user in automatically after finishing the sign-up process.
This API will automatically sign a user in if the autoSignIn flow has been completed in the following cases:- User confirmed their account with a verification code sent to their phone or email (default option).
- User confirmed their account with a verification link sent to their phone or email. In order to
enable this option you need to go to the Amazon Cognito console,
look for your userpool, then go to the
Messaging
tab and enablelink
mode inside theVerification message
option. Finally you need to define thesignUpVerificationMethod
in yourAuth
config.
Throws
AutoSignInException
- Thrown when the autoSignIn flow has not started, or has been cancelled/completed.
confirmResetPassword
Confirms the new password and verification code to reset the password.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The ConfirmResetPasswordInput object. |
Throws
ConfirmForgotPasswordException
Thrown due to an invalid confirmation code or password.AuthValidationErrorCode
Thrown due to an empty confirmation code, password or username.AuthTokenConfigException
- Thrown when the token provider config is invalid.
Returns
Promise<void>
confirmSignIn
Continues or completes the sign in process when required by the initial call to
signIn
.Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The ConfirmSignInInput object |
Throws
VerifySoftwareTokenException
: Thrown due to an invalid MFA token.RespondToAuthChallengeException
: Thrown due to an invalid auth challenge response.AssociateSoftwareTokenException
: Thrown due to a service error during the MFA setup process.AuthValidationErrorCode
: Thrown whenchallengeResponse
is not defined.AuthTokenConfigException
- Thrown when the token provider config is invalid.
confirmSignUp
Confirms a new user account.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The ConfirmSignUpInput object. |
Throws
ConfirmSignUpException
Thrown due to an invalid confirmation code.AuthValidationErrorCode
Thrown due to an empty confirmation codeAuthTokenConfigException
- Thrown when the token provider config is invalid.
confirmUserAttribute
Confirms a user attribute with the confirmation code.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The ConfirmUserAttributeInput object |
Throws
AuthValidationErrorCode
- Thrown whenconfirmationCode
is not defined.VerifyUserAttributeException
- Thrown due to an invalid confirmation code or attribute.AuthTokenConfigException
- Thrown when the token provider config is invalid.
Returns
Promise<void>
decodeJWT
Decodes payload of JWT token
Parameters
Option | Required | Type | Description |
---|---|---|---|
token | true | string | A string representing a token to be decoded |
Throws
Error
- Throws error when token is invalid or payload malformed.
deleteUser
Deletes a user from the user pool while authenticated.
Throws
DeleteUserException
AuthTokenConfigException
- Thrown when the token provider config is invalid.
Returns
Promise<void>
deleteUserAttributes
Deletes user attributes.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The DeleteUserAttributesInput object |
Throws
DeleteUserAttributesException
- Thrown due to invalid attribute.AuthTokenConfigException
- Thrown when the token provider config is invalid.
Returns
Promise<void>
fetchAuthSession
Fetch the auth session including the tokens and credentials if they are available. By default it
does not refresh the auth tokens or credentials if they are loaded in storage already. You can force a refresh
with
{ forceRefresh: true }
input.Parameters
Option | Required | Type | Description |
---|---|---|---|
options | false | Options configuring the fetch behavior. |
Throws
AuthError
- Throws error when session information cannot be refreshed.
Returns
Promise<>
fetchDevices
Fetches devices that have been remembered using rememberDevice
for the currently authenticated user.
Throws
ListDevicesException
AuthTokenConfigException
- Thrown when the token provider config is invalid.
fetchMFAPreference
Fetches the preferred MFA setting and enabled MFA settings for the user.
Throws
GetUserException
: error thrown when the service fails to fetch MFA preference and settings.AuthTokenConfigException
- Thrown when the token provider config is invalid.
Returns
Promise<>
fetchUserAttributes
Fetches the current user attributes while authenticated.
Throws
GetUserException
- Cognito service errors thrown when the service is not able to get the user.AuthTokenConfigException
- Thrown when the token provider config is invalid.
forgetDevice
Forget a remembered device while authenticated.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | false | The ForgetDeviceInput object. |
Throws
ForgetDeviceException
- Cognito service errors thrown when forgetting device with invalid device keyAuthTokenConfigException
- Thrown when the token provider config is invalid.
Returns
Promise<void>
getCurrentUser
Gets the current user from the idToken.
Throws
InitiateAuthException
- Thrown when the service fails to refresh the tokens.AuthTokenConfigException
- Thrown when the token provider config is invalid.
rememberDevice
Marks device as remembered while authenticated.
Throws
UpdateDeviceStatusException
- Cognito service errors thrown when setting device status to remembered using an invalid device key.AuthTokenConfigException
- Thrown when the token provider config is invalid.
Returns
Promise<void>
resendSignUpCode
Resend the confirmation code while signing up
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The ResendSignUpCodeInput object |
Throws
service:
ResendConfirmationException - Cognito service errors thrown when resending the code.validation:
AuthValidationErrorCode - Validation errors thrown either username are not defined.AuthTokenConfigException
- Thrown when the token provider config is invalid.
resetPassword
Resets a user's password.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The ResetPasswordInput object. |
Throws
ForgotPasswordException
Thrown due to an invalid confirmation code or password.AuthValidationErrorCode
Thrown due to an empty username.AuthTokenConfigException
- Thrown when the token provider config is invalid.
sendUserAttributeVerificationCode
Resends user's confirmation code when updating attributes while authenticated.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The SendUserAttributeVerificationCodeInput object |
Throws
GetUserAttributeVerificationException
AuthTokenConfigException
- Thrown when the token provider config is invalid.
signIn
Signs a user in
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The SignInInput object |
Throws
service:
InitiateAuthException, RespondToAuthChallengeException - Cognito service errors thrown during the sign-in process.validation:
AuthValidationErrorCode - Validation errors thrown when either username or password are not defined.AuthTokenConfigException
- Thrown when the token provider config is invalid.
signInWithRedirect
Signs in a user with OAuth. Redirects the application to an Identity Provider.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | false | The SignInWithRedirectInput object, if empty it will redirect to Cognito HostedUI |
Throws
AuthTokenConfigException
- Thrown when the user pool config is invalid.OAuthNotConfigureException
- Thrown when the oauth config is invalid.
Returns
Promise<void>
signOut
Signs a user out
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | false | The SignOutInput object |
Throws
AuthTokenConfigException
- Thrown when the token provider config is invalid.
Returns
Promise<void>
signUp
Creates a user
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The SignUpInput object |
Throws
service:
SignUpException - Cognito service errors thrown during the sign-up process.validation:
AuthValidationErrorCode - Validation errors thrown either username or password are not defined.AuthTokenConfigException
- Thrown when the token provider config is invalid.
updateMFAPreference
Updates the MFA preference of the user.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The UpdateMFAPreferenceInput object. |
Throws
SetUserMFAPreferenceException
- Service error thrown when the MFA preference cannot be updated.AuthTokenConfigException
- Thrown when the token provider config is invalid.
Returns
Promise<void>
updatePassword
Updates user's password while authenticated.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The UpdatePasswordInput object. |
Throws
ChangePasswordException
- Cognito service errors thrown when updating a password.AuthValidationErrorCode
- Validation errors thrown when oldPassword or newPassword are empty.AuthTokenConfigException
- Thrown when the token provider config is invalid.
Returns
Promise<void>
updateUserAttribute
Updates user's attribute while authenticated.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The UpdateUserAttributeInput object |
Throws
UpdateUserAttributesException
AuthTokenConfigException
- Thrown when the token provider config is invalid.
updateUserAttributes
Updates user's attributes while authenticated.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The UpdateUserAttributesInput object |
Throws
UpdateUserAttributesException
AuthTokenConfigException
- Thrown when the token provider config is invalid.
verifyTOTPSetup
Verifies an OTP code retrieved from an associated authentication app.
Parameters
Option | Required | Type | Description |
---|---|---|---|
input | true | The VerifyTOTPSetupInput |
Throws
VerifySoftwareTokenException
: Thrown due to an invalid MFA token.AuthValidationErrorCode
: Thrown whencode
is not defined.AuthTokenConfigException
- Thrown when the token provider config is invalid.
Returns
Promise<void>
Link Color Legend
Interface
Reference
Other