Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot pass prompt=select_account to Microsoft oauth flow using MicrosoftBuilder().setCustomParameters #1805

Closed
organicinternet opened this issue Jul 8, 2020 · 2 comments

Comments

@organicinternet
Copy link

  • Android device: Pixel 2
  • Android OS version: 10 - 5 June 2020
  • Google Play Services version: 20.24.14
  • Firebase/Play Services SDK version: 17.0.0
  • FirebaseUI version: 6.2.1

Step 3: Describe the problem:

I want to pass prompt=select_account to the Microsoft oauth flow to display the account picker. I'm using this code in the provider setup:

AuthUI.IdpConfig.MicrosoftBuilder().setCustomParameters(hashMapOf("prompt" to "select_account")).build()

The parameters are not passed to the flow and authentication continues without offering a choice of accounts.

Steps to reproduce:

  1. Set up a Microsoft auth provider passing the prompt=account custom parameter:

AuthUI.IdpConfig.MicrosoftBuilder().setCustomParameters(hashMapOf("prompt" to "select_account")).build()

  1. Press "Sign in with Microsoft" provider button to start the sign in activity

Observed Results:

The following error shows in the log, and the prompt parameter is not passed to the flow:

2020-07-08 10:18:01.200 19752-19752/com.---.--- W/Bundle: Key generic_oauth_custom_parameters expected Parcelable but value was a java.util.HashMap.  The default value <null> was returned.
2020-07-08 10:18:01.204 19752-19752/com.---.--- W/Bundle: Attempt to cast generated internal exception:
    java.lang.ClassCastException: java.util.HashMap cannot be cast to android.os.Parcelable
        at android.os.Bundle.getParcelable(Bundle.java:957)
        at com.firebase.ui.auth.data.remote.GenericIdpSignInHandler.buildOAuthProvider(GenericIdpSignInHandler.java:205)
        at com.firebase.ui.auth.data.remote.GenericIdpSignInHandler.startSignIn(GenericIdpSignInHandler.java:69)
        at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity$3.onClick(AuthMethodPickerActivity.java:350)
        at android.view.View.performClick(View.java:7259)
        at android.view.View.performClickInternal(View.java:7236)
        at android.view.View.access$3600(View.java:801)
        at android.view.View$PerformClick.run(View.java:27892)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Expected Results:

The custom parameter "prompt" should be passed to the flow causing the account picker to display

Relevant Code:

AuthUI.IdpConfig.MicrosoftBuilder().setCustomParameters(hashMapOf("prompt" to "select_account")).build()

setCustomParameters appears to call putSerializable() with the given HashMap: https://github.com/firebase/FirebaseUI-Android/blob/version-6.2.1/auth/src/main/java/com/firebase/ui/auth/AuthUI.java#L1191

but the flow uses getParcelable() to retrieve the parameters: https://github.com/firebase/FirebaseUI-Android/blob/version-6.2.1/auth/src/main/java/com/firebase/ui/auth/data/remote/GenericIdpSignInHandler.java#L205

@samtstern samtstern added this to the 6.3.0 milestone Jul 8, 2020
@samtstern
Copy link
Contributor

@organicinternet thanks for filing this! As you said, looks like the bug comes from right here:

This should be a simple fix.

@samtstern
Copy link
Contributor

This issue is fixed and released in version 6.3.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants