amplify-android icon indicating copy to clipboard operation
amplify-android copied to clipboard

com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Token is not from a supported provider of this identity pool.

Open AsitDixit opened this issue 3 years ago • 1 comments

Before opening, please confirm:

Language and Async Model

Java

Amplify Categories

Authentication

Gradle script dependencies

`dependencies {

implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.amplifyframework:core:1.36.1'
implementation 'com.google.android.gms:play-services-auth:20.2.0'
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5'
implementation "androidx.multidex:multidex:2.0.1"
implementation 'com.amplifyframework:aws-auth-cognito:1.36.1'
implementation "com.google.android.gms:play-services-auth:20.2.0"
implementation 'com.amazonaws:aws-android-sdk-auth-google:2.49.0'

}`

Environment information

# Put output below this line
gradle version:7.3.3

Please include any relevant guides or documentation you're referencing

No response

Describe the bug

I'm using federatedSignIn in my android app.When I'm passing GoogleSignInAccount.getIdToken.() it is showing the above error. see my code snippet and log.

Reproduction steps (if applicable)

No response

Code Snippet

// Put your code below this line.
    void cognitoAuthWithGoogle(GoogleSignInAccount account){
        AWSMobileClient.getInstance().federatedSignIn(IdentityProvider.GOOGLE.toString(), account.getIdToken().toString(), new Callback<UserStateDetails>() {
            @Override
            public void onResult(final UserStateDetails userStateDetails) {
                Toast.makeText(MainActivity.this, "Success", Toast.LENGTH_SHORT).show();
            }
            @Override
            public void onError(Exception e) {
                Log.e("TAG", "sign-in error", e);
            }

Log output

// Put your logs below this line
2022-07-16 11:26:56.264 22836-25026/com.example.socialsigngoogle E/TAG: sign-in error
    java.lang.RuntimeException: Error in federating the token.
        at com.amazonaws.mobile.client.AWSMobileClient$11.run(AWSMobileClient.java:1907)
        at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
        at java.lang.Thread.run(Thread.java:922)
     Caused by: com.amazonaws.services.cognitoidentity.model.NotAuthorizedException: Token is not from a supported provider of this identity pool. (Service: AmazonCognitoIdentity; Status Code: 400; Error Code: NotAuthorizedException; Request ID:  xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
        at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:742)
        at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:420)
        at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:229)
        at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.invoke(AmazonCognitoIdentityClient.java:1836)
        at com.amazonaws.services.cognitoidentity.AmazonCognitoIdentityClient.getId(AmazonCognitoIdentityClient.java:809)
        at com.amazonaws.auth.AWSAbstractCognitoIdentityProvider.getIdentityId(AWSAbstractCognitoIdentityProvider.java:172)
        at com.amazonaws.mobile.client.AWSMobileClientCognitoIdentityProvider.refresh(AWSMobileClient.java:4078)
        at com.amazonaws.auth.CognitoCredentialsProvider.startSession(CognitoCredentialsProvider.java:687)
        at com.amazonaws.auth.CognitoCredentialsProvider.refresh(CognitoCredentialsProvider.java:640)
        at com.amazonaws.auth.CognitoCachingCredentialsProvider.refresh(CognitoCachingCredentialsProvider.java:511)
        at com.amazonaws.mobile.client.AWSMobileClient.federateWithCognitoIdentity(AWSMobileClient.java:1938)
        at com.amazonaws.mobile.client.AWSMobileClient$11.run(AWSMobileClient.java:1894)
        at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101) 
        at java.lang.Thread.run(Thread.java:922) 

amplifyconfiguration.json

No response

GraphQL Schema

// Put your schema below this line


Additional information and screenshots

No response

AsitDixit avatar Jul 16 '22 06:07 AsitDixit

The error suggests that the identity pool used to federated Google account is not configured with Google. Please check your identity pool configuration in Cognito.

div5yesh avatar Aug 05 '22 22:08 div5yesh

Closing the issue due to inactivity. Please create another issue if you are still facing this problem.

div5yesh avatar Aug 15 '22 17:08 div5yesh

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Aug 15 '22 17:08 github-actions[bot]