Repository navigation
Credential sign-in, account linking and the custom-token UID fix on BoM 34.18.0 (#69 and #71) - #73
Merged
Merged
Conversation
verifyCustomToken does not return the user's UID, and getAccountInfo returns the profile under users[0]. The user was therefore created with an empty UID and the profile fields were read from the wrong level. Resolve the UID from the response, then users[0].localId, then the ID token's user_id / sub claims, and fail the task instead of signing in without one. Read lookup profile fields from users[0], run the lookup only after a successful token exchange, and complete the pending task on parse errors. Co-Authored-By: GPT-6 <noreply@openai.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merges TomislavMladenov's jvm-auth-credential-support onto the BoM 34.18.0 master. Conflicts were the OkHttp 4 forms FirebaseAuth moved to in #72, applied to the branch's new code and its MockWebServer test, and the mockwebserver artifact pinned to 4.12.0 alongside okhttp.
…iles Merges KadirJeager's fix/custom-token-uid on top of #69. Where both changed the sign-in response handler, #69's try-wrapped version already covers #71's inner catch; the account lookup keeps #71's users[0] profile parsing and UID resolution. The test's wildcard import is expanded, as ktlint rejects it.
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved session races can restore signed-out users or mix account identities, and token and profile handling need correction.
6 open issues
Bind lookup responses to their initiating session · New Prevent late link responses from restoring inactive sessions · New Preserve provider-specific identities and profiles · New Populate custom-token users with profile fields · New Clear stale email verification after email changes · New Refresh expired tokens before linking accounts · New
What changed in this PR
Integrates JVM credential sign-in, account linking, and custom-token UID fixes with the existing Firebase BoM 34.18.0 and OkHttp 4 changes.
Changes:
- Implements Google, OAuth, and phone credentials, sign-in, and account linking.
- Adds UID fallback resolution, account lookup parsing, and persisted user metadata.
- Makes callback dispatch configurable and adds authentication and dispatcher tests.
| File | Description |
|---|---|
src/test/kotlin/FirebasePlatformDispatcherTest.kt |
Tests callback thread affinity and posting order. |
src/test/kotlin/FirebaseAuthCredentialTest.kt |
Tests credentials, linking, persistence, refresh, and listeners. |
src/test/kotlin/com/google/firebase/auth/AuthIdentityTest.kt |
Tests UID resolution and lookup profile parsing. |
src/main/java/com/google/firebase/FirebasePlatform.kt |
Adds configurable main dispatcher and shared scope. |
src/main/java/com/google/firebase/auth/Stubs.kt |
Implements user metadata, provider information, and phone credentials. |
src/main/java/com/google/firebase/auth/PhoneAuthProvider.java |
Implements phone credential creation. |
src/main/java/com/google/firebase/auth/OAuthProvider.java |
Implements OAuth configuration and credential builders. |
src/main/java/com/google/firebase/auth/OAuthCredential.java |
Adds validated OAuth credentials. |
src/main/java/com/google/firebase/auth/GoogleAuthProvider.java |
Implements Google credential creation and constants. |
src/main/java/com/google/firebase/auth/GoogleAuthCredential.java |
Adds validated Google credentials. |
src/main/java/com/google/firebase/auth/FirebaseUser.kt |
Exposes implemented profile properties and linking. |
src/main/java/com/google/firebase/auth/FirebaseAuth.kt |
Implements credential flows and updates identity, profile, and token handling. |
src/main/java/com/google/firebase/auth/AuthIdentity.kt |
Adds account profile extraction and UID fallbacks. |
src/main/java/com/google/firebase/auth/AuthCredential.java |
Adds credential validation, encoding, and secret-safe string output. |
src/main/java/android/os/Handler.kt |
Routes callbacks through the platform scope. |
src/main/java/android/os/AsyncTask.kt |
Uses the platform dispatcher for main-thread callbacks. |
gradle/libs.versions.toml |
Pins MockWebServer to OkHttp-compatible version 4.12.0. |
build.gradle.kts |
Adds MockWebServer for tests. |
Review effort: Balanced
Comment on lines
+469
to
+471
| val previous = requireNotNull(user) { "No user for account lookup" } | ||
| user = previous.copy( | ||
| uid = responseUid(data, previous.idToken), |
Comment on lines
+932
to
+936
| if (linkedUser.uid != signedInUser.uid) { | ||
| throw FirebaseAuthInvalidUserException( | ||
| "ERROR_USER_MISMATCH", | ||
| "The linked credential returned a different Firebase user." | ||
| ) |
| get() = FirebaseUserMetadata(createdAt, lastSignInAt) | ||
|
|
||
| override val providerData: List<UserInfo> | ||
| get() = providerIds.map { provider -> UserInfo(displayName, email, phoneNumber, photoUrl, provider, uid) } |
| createdAt = profile["createdAt"]?.jsonPrimitive?.longOrNull ?: previous.createdAt, | ||
| email = profile["email"]?.jsonPrimitive?.contentOrNull ?: previous.email, | ||
| photoUrl = profile["photoUrl"]?.jsonPrimitive?.contentOrNull ?: previous.photoUrl, | ||
| displayName = profile["displayName"]?.jsonPrimitive?.contentOrNull ?: previous.displayName |
| displayName = newBody["displayName"]?.jsonPrimitive?.contentOrNull ?: prev.displayName | ||
| displayName = newBody["displayName"]?.jsonPrimitive?.contentOrNull ?: prev.displayName, | ||
| phoneNumber = prev.phoneNumber, | ||
| isEmailVerified = prev.isEmailVerified, |
| ) | ||
| } | ||
|
|
||
| return enqueueCredentialAuthPost(authCredential, currentIdToken = signedInUser.idToken) { responseBody -> |
This was referenced Oct 26, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Integration branch for the two open auth PRs, which conflict with #72's move to OkHttp 4 and cannot be merged from their forks as they stand. It carries the authors' commits unchanged, each followed by a merge commit with the conflict resolution.
FirebaseAuthmoved to in Bump the Firebase Android BoM to 34.18.0 #72, applied to the branch's new code and to its MockWebServer test, and themockwebserverartifact pinned to 4.12.0 alongsideokhttp.users[0]profile parsing and UID resolution. The test's wildcard import is expanded, as ktlint rejects it.The full suite passes under the emulator: 34 tests (the original 12, #69's 16 and #71's 6). Supersedes #69 and #71, which can be closed once this merges, with the authors credited by their commits.