Skip to content

Credential sign-in, account linking and the custom-token UID fix on BoM 34.18.0 (#69 and #71) - #73

Merged
nbransby merged 5 commits into
masterfrom
integrate-auth
Oct 26, 2026
Merged

nbransby merged 5 commits into
masterfrom
integrate-auth

Conversation

@nbransby

@nbransby nbransby commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

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.

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.

TomislavMladenov and others added 5 commits September 2, 2026 23:22
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.
Copilot AI balanced review requested due to automatic review settings October 26, 2026 11:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved session races can restore signed-out users or mix account identities, and token and profile handling need correction.

6 open issues
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 ->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants