Search in sources :

Example 1 with GetUserResult

use of com.amazonaws.services.cognitoidentityprovider.model.GetUserResult in project aws-sdk-android by aws-amplify.

the class CognitoUser method getUserDetailsInternal.

/**
 * Internal method to fetch user attributes.
 *
 * @param session REQUIRED: {@link CognitoUserSession}
 * @return User attributes
 */
private CognitoUserDetails getUserDetailsInternal(CognitoUserSession session) {
    if (session != null && session.isValid()) {
        final GetUserRequest getUserRequest = new GetUserRequest();
        getUserRequest.setAccessToken(session.getAccessToken().getJWTToken());
        final GetUserResult userResult = cognitoIdentityProviderClient.getUser(getUserRequest);
        return new CognitoUserDetails(new CognitoUserAttributes(userResult.getUserAttributes()), new CognitoUserSettings(userResult.getMFAOptions()));
    } else {
        throw new CognitoNotAuthorizedException("user is not authenticated");
    }
}
Also used : GetUserResult(com.amazonaws.services.cognitoidentityprovider.model.GetUserResult) GetUserRequest(com.amazonaws.services.cognitoidentityprovider.model.GetUserRequest) CognitoNotAuthorizedException(com.amazonaws.mobileconnectors.cognitoidentityprovider.exceptions.CognitoNotAuthorizedException)

Aggregations

CognitoNotAuthorizedException (com.amazonaws.mobileconnectors.cognitoidentityprovider.exceptions.CognitoNotAuthorizedException)1 GetUserRequest (com.amazonaws.services.cognitoidentityprovider.model.GetUserRequest)1 GetUserResult (com.amazonaws.services.cognitoidentityprovider.model.GetUserResult)1