Skip to content

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

Closed
@organicinternet

Description

@organicinternet
  • 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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions