Skip to content

Commit 3529895

Browse files
authored
Fix serializable error with custom parameters (#1809)
1 parent c5185f7 commit 3529895

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixes issue with custom parameters for OAuth providers (#1805)

auth/src/main/java/com/firebase/ui/auth/data/remote/GenericIdpSignInHandler.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import com.google.firebase.auth.OAuthCredential;
4040
import com.google.firebase.auth.OAuthProvider;
4141

42+
import java.util.HashMap;
4243
import java.util.List;
4344
import java.util.Map;
4445

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

201202
List<String> scopes =
202203
getArguments().getParams().getStringArrayList(ExtraConstants.GENERIC_OAUTH_SCOPES);
203-
Map<String, String> customParams =
204-
getArguments().getParams()
205-
.getParcelable(ExtraConstants.GENERIC_OAUTH_CUSTOM_PARAMETERS);
204+
205+
// This unchecked cast is safe, this extra is put in as a serializable
206+
// in AuthUI.setCustomParameters
207+
HashMap<String, String> customParams =
208+
(HashMap<String, String>) getArguments().getParams()
209+
.getSerializable(ExtraConstants.GENERIC_OAUTH_CUSTOM_PARAMETERS);
206210

207211
if (scopes != null) {
208212
providerBuilder.setScopes(scopes);

auth/src/test/java/com/firebase/ui/auth/viewmodel/GenericIdpSignInHandlerTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.firebase.ui.auth.testhelpers.TestHelper;
2323
import com.firebase.ui.auth.ui.HelperActivityBase;
2424
import com.firebase.ui.auth.ui.idp.WelcomeBackIdpPrompt;
25+
import com.firebase.ui.auth.util.ExtraConstants;
2526
import com.firebase.ui.auth.util.data.AuthOperationManager;
2627
import com.firebase.ui.auth.viewmodel.email.EmailLinkSignInHandler;
2728
import com.google.firebase.auth.AuthCredential;
@@ -69,8 +70,6 @@ public class GenericIdpSignInHandlerTest {
6970
private static final String DISPLAY_NAME = "displayName";
7071
private static final String EMAIL = "email";
7172
private static final String SCOPE = "scope";
72-
private static final String CUSTOM_PARAMETER_KEY = "customParameterKey";
73-
private static final String CUSTOM_PARAMETER_VALUE = "customParameterValue";
7473

7574
private GenericIdpSignInHandler mHandler;
7675

@@ -99,8 +98,9 @@ public void setUp() {
9998
mHandler = new GenericIdpSignInHandler(
10099
(Application) ApplicationProvider.getApplicationContext());
101100

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

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

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

128+
HashMap<String, String> customArgs = (HashMap<String, String>) mHandler.getArguments().getParams()
129+
.getSerializable(ExtraConstants.GENERIC_OAUTH_CUSTOM_PARAMETERS);
130+
assertThat(customArgs).isNotNull();
131+
assertThat(customArgs).hasSize(1);
132+
128133
InOrder inOrder = inOrder(mResponseObserver);
129134
inOrder.verify(mResponseObserver)
130135
.onChanged(argThat(ResourceMatchers.<IdpResponse>isLoading()));

0 commit comments

Comments
 (0)