Search in sources :

Example 1 with NotAuthorizedException

use of com.amazonaws.services.cognitoidentity.model.NotAuthorizedException in project aws-sdk-android by aws-amplify.

the class OAuth2Utils method getCredentials.

@Override
public AWSCredentials getCredentials() {
    if (isLegacyMode()) {
        return IdentityManager.getDefaultIdentityManager().getCredentialsProvider().getCredentials();
    }
    if (cognitoIdentity == null) {
        throw new AmazonClientException("Cognito Identity not configured");
    }
    try {
        if (waitForSignIn()) {
            Log.d(TAG, "getCredentials: Validated user is signed-in");
        }
        AWSSessionCredentials credentials = cognitoIdentity.getCredentials();
        mStore.set(IDENTITY_ID_KEY, cognitoIdentity.getIdentityId());
        return credentials;
    } catch (NotAuthorizedException e) {
        Log.w(TAG, "getCredentials: Failed to getCredentials from Cognito Identity", e);
        throw new AmazonClientException("Failed to get credentials from Cognito Identity", e);
    } catch (Exception e) {
        throw new AmazonClientException("Failed to get credentials from Cognito Identity", e);
    }
}
Also used : AmazonClientException(com.amazonaws.AmazonClientException) AWSSessionCredentials(com.amazonaws.auth.AWSSessionCredentials) NotAuthorizedException(com.amazonaws.services.cognitoidentity.model.NotAuthorizedException) JSONException(org.json.JSONException) InvalidUserPoolConfigurationException(com.amazonaws.services.cognitoidentityprovider.model.InvalidUserPoolConfigurationException) AmazonClientException(com.amazonaws.AmazonClientException) NotAuthorizedException(com.amazonaws.services.cognitoidentity.model.NotAuthorizedException)

Example 2 with NotAuthorizedException

use of com.amazonaws.services.cognitoidentity.model.NotAuthorizedException in project aws-sdk-android by aws-amplify.

the class NotAuthorizedExceptionUnmarshaller method unmarshall.

@Override
public AmazonServiceException unmarshall(JsonErrorResponse error) throws Exception {
    NotAuthorizedException e = (NotAuthorizedException) super.unmarshall(error);
    e.setErrorCode("NotAuthorizedException");
    return e;
}
Also used : NotAuthorizedException(com.amazonaws.services.cognitoidentity.model.NotAuthorizedException)

Aggregations

NotAuthorizedException (com.amazonaws.services.cognitoidentity.model.NotAuthorizedException)2 AmazonClientException (com.amazonaws.AmazonClientException)1 AWSSessionCredentials (com.amazonaws.auth.AWSSessionCredentials)1 InvalidUserPoolConfigurationException (com.amazonaws.services.cognitoidentityprovider.model.InvalidUserPoolConfigurationException)1 JSONException (org.json.JSONException)1