Aws-sdk-android: Hosted UI says "Login option is not available"

Created on 2 Jun 2020  路  4Comments  路  Source: aws-amplify/aws-sdk-android

Hello, I've successfully integrated the Hosted UI in a flutter plugin.

But it shows the following error message "Login option is not available. Please try another one" -

Both google sign in and username+password sign in seem to work fine, so users might get tripped up from seeing that error.


Am I doing something wrong here?

val hostedUIOptions = HostedUIOptions.builder()
    .scopes("email", "openid")
    .identityProvider("google")
    .build()
val signInUIOptions = SignInUIOptions.builder()
    .hostedUIOptions(hostedUIOptions)
    .build()

AWSMobileClient.getInstance().showSignIn(
    activity,
    signInUIOptions,
    object : Callback<UserStateDetails> {
        override fun onResult(details: UserStateDetails) {
            Log.d("TAG", "onResult: " + details.getUserState());
        }

        override fun onError(e: Exception) {
            Log.e("TAG", "onError: ", e);
        }
    }
)

Links to code on Github -

  1. Invoke showSignIn()

  2. Override onNewIntent

  3. The intent filter in AndroidManifest.xml

  4. The list of dependencies -

    implementation 'com.amazonaws:aws-android-sdk-mobile-client:2.16.12'
    implementation 'com.amazonaws:aws-android-sdk-cognitoauth:2.16.12'

Hope this information is sufficient in helping me debug this issue.

AWSMobileClient Usage Question

All 4 comments

My awsconfiguration.json -

{
  "UserAgent": "aws-amplify-cli/0.1.0",
  "Version": "1.0",
  "IdentityManager": {
    "Default": {}
  },
  "CredentialsProvider": {
    "CognitoIdentity": {
      "Default": {
        "PoolId": "ap-south-1:XXXX-XXX",
        "Region": "ap-south-1"
      }
    }
  },
  "CognitoUserPool": {
    "Default": {
      "PoolId": "ap-south-1_XXXX",
      "AppClientId": "XXXX",
      "Region": "ap-south-1"
    }
  },
  "Auth": {
    "Default": {
      "OAuth": {
        "WebDomain": "XXXX.auth.ap-south-1.amazoncognito.com",
        "AppClientId": "XXXX",
        "SignInRedirectURI": "myapp://callback",
        "SignOutRedirectURI": "myapp://signout",
        "Scopes": ["email", "openid"]
      }
    }
  }
}

@devxpy I had the same issue with the react native app. I figured out that it happens when you give an unidentified string as the identity provider. In your example, the identity provider of the hostedUIOptions should be set to 'Google' instead of 'google'. I believe Cognito assumes 'google' as a custom identity provider, and hence throws the error because there is no provider with that name associated with your app. Hope that helps!
@TrekSoft It'd be great if the value for identity provider is an enum instead of strings with strict case rules. Also, the error showed on the hosted UI is not very helpful.

Hey, yeah in Android Amplify (which we recommend using over raw AWSMobileClient for end users) we actually do have enums for those values. Although this is very interesting that the lowercase throws that error since I see we currently have our enums set to the lowercase values (although the old AWSMobileClient documentation shows the values capitalized) so I'll double check this on our end.

Ah, yeah I checked into this and I see we have a converter where we convert the Amplify local constants to the AWS Cognito specific values and they are capitalized there. So I'll go ahead and close this. Thanks again for your response An0r4k.

Was this page helpful?
0 / 5 - 0 ratings