Skip to content

Fix serializable error with custom parameters #1809

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

Merged
merged 1 commit into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fixes issue with custom parameters for OAuth providers (#1805)
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.google.firebase.auth.OAuthCredential;
import com.google.firebase.auth.OAuthProvider;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -200,9 +201,12 @@ protected OAuthProvider buildOAuthProvider(String providerId) {

List<String> scopes =
getArguments().getParams().getStringArrayList(ExtraConstants.GENERIC_OAUTH_SCOPES);
Map<String, String> customParams =
getArguments().getParams()
.getParcelable(ExtraConstants.GENERIC_OAUTH_CUSTOM_PARAMETERS);

// This unchecked cast is safe, this extra is put in as a serializable
// in AuthUI.setCustomParameters
HashMap<String, String> customParams =
(HashMap<String, String>) getArguments().getParams()
.getSerializable(ExtraConstants.GENERIC_OAUTH_CUSTOM_PARAMETERS);

if (scopes != null) {
providerBuilder.setScopes(scopes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.firebase.ui.auth.testhelpers.TestHelper;
import com.firebase.ui.auth.ui.HelperActivityBase;
import com.firebase.ui.auth.ui.idp.WelcomeBackIdpPrompt;
import com.firebase.ui.auth.util.ExtraConstants;
import com.firebase.ui.auth.util.data.AuthOperationManager;
import com.firebase.ui.auth.viewmodel.email.EmailLinkSignInHandler;
import com.google.firebase.auth.AuthCredential;
Expand Down Expand Up @@ -69,8 +70,6 @@ public class GenericIdpSignInHandlerTest {
private static final String DISPLAY_NAME = "displayName";
private static final String EMAIL = "email";
private static final String SCOPE = "scope";
private static final String CUSTOM_PARAMETER_KEY = "customParameterKey";
private static final String CUSTOM_PARAMETER_VALUE = "customParameterValue";

private GenericIdpSignInHandler mHandler;

Expand Down Expand Up @@ -99,8 +98,9 @@ public void setUp() {
mHandler = new GenericIdpSignInHandler(
(Application) ApplicationProvider.getApplicationContext());

// See https://github.com/firebase/FirebaseUI-Android/issues/1805
Map<String, String> customParams = new HashMap<>();
customParams.put(CUSTOM_PARAMETER_KEY, CUSTOM_PARAMETER_VALUE);
customParams.put("prompt", "select_account");

AuthUI.IdpConfig config
= new AuthUI.IdpConfig.MicrosoftBuilder()
Expand All @@ -125,6 +125,11 @@ public void testStartSignIn_normalSignInFlow_expectSuccess() {

assertThat(providerCaptor.getValue().getProviderId()).isEqualTo(MICROSOFT_PROVIDER);

HashMap<String, String> customArgs = (HashMap<String, String>) mHandler.getArguments().getParams()
.getSerializable(ExtraConstants.GENERIC_OAUTH_CUSTOM_PARAMETERS);
assertThat(customArgs).isNotNull();
assertThat(customArgs).hasSize(1);

InOrder inOrder = inOrder(mResponseObserver);
inOrder.verify(mResponseObserver)
.onChanged(argThat(ResourceMatchers.<IdpResponse>isLoading()));
Expand Down