ram munda
ram munda

Reputation: 23

AWS-Amplify Auth: Error Failed to initialize OAuth, please check your awsconfiguration.json

Getting error while using amplify auth with social sign-in

E/MyAmplifyApp: Could not initialize Amplify
    AuthException{message=Failed to instantiate AWSMobileClient, cause=java.lang.RuntimeException: Failed to initialize OAuth, please check your awsconfiguration.json, recoverySuggestion=See attached exception for more details}

 Caused by: java.lang.RuntimeException: Failed to initialize OAuth, please check your awsconfiguration.json
        at com.amazonaws.mobile.client.AWSMobileClient$2.run(AWSMobileClient.java:626)
        at com.amazonaws.mobile.client.internal.InternalCallback$1.run(InternalCallback.java:101)
        at java.lang.Thread.run(Thread.java:923)
     Caused by: org.json.JSONException: No value for WebDomain

This is in JSON

"WebDomain": "amplifyandroi[...].auth.ap-south-amazoncognito.com",
"AppClientId": "[id]",
"SignInRedirectURI": "app://",
"SignOutRedirectURI": "app://",
"Scopes": [
           "phone",
           "email",
           "openid",
           "profile",
           "aws.cognito.signin.user.admin"
          ]

Upvotes: 2

Views: 1278

Answers (1)

Jared Anderton
Jared Anderton

Reputation: 1026

I had this same issue on Android, the problem I faced, is that my amplifyconfiguration.json had extra settings, for the hosted UI, which I wasn't using. By removing them, I was able to get passed the issue. In the end my amplifyconfiguration.json looked like this:

{
    "auth": {
        "plugins": {
            "awsCognitoAuthPlugin": {
                "CognitoUserPool": {
                    "Default": {
                        "PoolId": "us-east-1_xxxxxxxx",
                        "AppClientId": "xxxxxxxxxxxxxxxx",
                        "Region": "us-east-1"
                    }
                }
            }
        }
    }
}

Note: I only use a user pool, not an identity pool, so I was able to remove even more from the default json structure from AWS's documentation.

Upvotes: 2

Related Questions