AWSMobileClient
AWSMobileClient
is used for all auth related operations when your app is accessing AWS backend.
-
Returns the current state of user. If MobileClient is not initialized, it will return
unknown
-
-
The default instance of
AWSMobileClient
. The configuration is loaded from theawsconfiguration.json
file.You can manage your own instance of
AWSMobileClient
by constructing it withAWSMobileClient(configuration)
, however please note that multiple instances of AWSMobileClient is not supported.Implementation Notes:
The
AWSMobileClient
relies onAWSInfo
for configuration and once that class is initialized, the configuration cannot be reset and/or re-initialized. Therefore, even though you can instantiateAWSMobileClient
multiple times, all instances will have the same configuration reference. -
Initializes
AWSMobileClient
and determines theUserState
for current user using cache. -
Adds a listener who receives notifications on user state change.
-
Removes a registered listener. If no listener exists, call is ignored.
-
Updates the service configuration for the Cognito Services
Warning
This method is intended for internal use only. -
Returns the username attribute of the access token for the current logged in user, nil otherwise. Note that the value stored may vary depending on how sign-in was performed. @see https://docs.aws.amazon.com/cognito/latest/developerguide/amazon-cognito-user-pools-using-tokens-with-identity-providers.html#amazon-cognito-user-pools-using-the-access-token
-
-
The identity id associated with this provider. This value will be fetched from the keychain at startup. If you do not want to reuse the existing identity id, you must call the clearKeychain method. If the identityId is not fetched yet, it will return nil. Use
getIdentityId()
method to force a server fetch when identityId is not available. -
Returns true if there is a user currently signed in.
-
-
Fetches the
AWSCredentials
asynchronously. -
Asynchronous deleteUser method which requires network activity.
-
When called, will send a confirmation code to user which can be used to reset the password.
-
Resets the password for the user if they have a valid confirmation code using the specified new password.
-
Change password of a logged in user.
-
Signs in a user with the given username and password.
-
Confirm a sign in which requires additional validation via steps like SMS MFA.
-
Federates a social provider like Google, Facebook, Amazon or Twitter. If user is already signed in through the
signIn
method, it will returnAWSMobileClientError.federationProviderExists
error. If federation provider name has changed, previous federation provider’s token will be erased and the new token will be used going forward; the user state is un-affected in that case. -
Shows a fully managed sign in screen which allows users to sign up and sign in.
-
-
-
Asynchronous signout method which requires network activity. Based on the options specified in
SignOutOptions
, appropriate tasks will be performed. -
Signs out the current logged in user and clears the local keychain store. Note: This does not invalidate the tokens from the service or sign out the user from other devices.
-
Invoke this function to release any sign-in waits. When you receive a notifcation which is
signedOutFederatedTokensInvalid
orsignedOutUserPoolsTokensInvalid
you need to provide SDK the token viafederate
method or call thesignIn
method and complete the sign-in flow. If you can’t get the latest token from the user, you can call this method to un-block any waiting calls. -
Sign up with username, password and other attrbutes like phone, email.
-
Confirms a sign up for a user using a verification code.
-
Re-sends the sign up code to the user via email or phone_number.
-
Returns cached UserPools auth JWT tokens if valid. If the
idToken
is not valid, and a refresh token is available, refresh token is used to get a newidToken
. If there is no refresh token and the user is signed in, a notification is dispatched to indicate requirement of user to re-signin. The call to wait will be synchronized so that if multiple threads call this method, they will block till the first thread gets the token. -
Verify a user attribute like phone_number.
This method is only valid for users signed in via UserPools (either directly or via HostedUI).
-
Update the attributes for a user.
This method is only valid for users signed in via UserPools (either directly or via HostedUI).
-
Fetches the attributes for logged in user.
This method is only valid for users signed in via UserPools (either directly or via HostedUI).
-
Confirm the updated attributes using a confirmation code.
This method is only valid for users signed in via UserPools (either directly or via HostedUI).
-
Confirm the attribute using a confirmation code.
This method is only valid for users signed in via UserPools (either directly or via HostedUI).
-
Asynchronously returns a valid AWS credentials or an error object if it cannot retrieve valid credentials. It should cache valid credentials as much as possible and refresh them when they are invalid.
-
Invalidates the cached temporary AWS credentials. If the credentials provider does not cache temporary credentials, this operation is a no-op.
-
Get/retrieve the identity id for this provider. If an identity id is already set on this provider, no remote call is made and the identity will be returned as a result of the AWSTask (the identityId is also available as a property). If no identityId is set on this provider, one will be retrieved from the service.
-
Clear the cached AWS credentials for this provider.
-
Clear ALL saved values for this provider (identityId, credentials, logins).
-
Each entry in logins represents a single login with an identity provider. The key is the domain of the login provider (e.g. ‘graph.facebook.com’) and the value is the OAuth/OpenId Connect token that results from an authentication with that login provider.