Repository navigation
Align the Auth API with the Firebase Android SDK - #82
Merged
Merged
Conversation
Every public Auth class and member the Android SDK declares and this port lacked is added, and the four places where the port's shape differed are aligned, so that code written against the Android SDK compiles and links against this one: FirebaseUser.getPhotoUrl returns a Uri, FirebaseUser implements the UserInfo interface (which gains isEmailVerified), the ActionCodeInfo types are classes, and the profile change request exposes its display name and photo URI. AuthResult gains getAdditionalUserInfo and getCredential, filled from the sign-in response. The providers expose their PROVIDER_ID and sign-in method constants and create the Android credential types, including EmailAuthCredential for a password or a sign-in link, which signInWithCredential and linkWithCredential accept. OAuthCredential is the Android abstract class over a package-private implementation, OAuthProvider extends FederatedAuthProvider and its builders expose their state. ActionCodeSettings is implemented and travels with every action email, and ActionCodeUrl parses an action link, unwrapping a Dynamic Link. FirebaseAuth gains sendPasswordResetEmail, sendSignInLinkToEmail, signInWithEmailLink, isSignInWithEmailLink, checkActionCode, verifyPasswordResetCode, confirmPasswordReset, applyActionCode, fetchSignInMethodsForEmail, updateCurrentUser, revokeAccessToken, the language code (sent as X-Firebase-Locale), useAppLanguage, the tenant id, the custom auth domain, getFirebaseAuthSettings, getPendingAuthResult and initializeRecaptchaConfig; FirebaseUser gains sendEmailVerification, updatePhoneNumber(PhoneAuthCredential), verifyBeforeUpdateEmail(String) and getTenantId. PhoneAuthOptions, the multi-factor info, assertion and generator types, TotpSecret, FirebaseAuthSettings, FirebaseAuthProvider and the exception members (FirebaseAuthUserCollisionException's email and credential, FirebaseAuthWeakPasswordException's reason, FirebaseAuthMultiFactorException's resolver, FirebaseAuthMissingActivityForRecaptchaException) complete the surface; what needs a device or a browser (phone verification, multi-factor, Activity flows) is present and fails with a clear message. FirebaseAuthApiTest covers the shapes without a server and FirebaseAuthEmailFlowsTest runs the action-code flows against the Auth emulator; the README describes what the port now supports.
There was a problem hiding this comment.
🟡 Changes recommended
Critical authentication flaws remain, including cross-project token acceptance, session-credential exposure in logs, and unintended password changes when linking an already-linked provider.
10 open issues
Redact session credentials from AuthResult.toString() · New Return null from Void operations to avoid Kotlin Unit casts · New Reject linking a password provider that's already linked · New Validate token audience before persisting a signed-in user · New Reject non-sign-in action codes for email-link sign-in · New Include the Firebase locale header in action-email requests · New Refresh the ID token before sending verification email · New Preserve additional user info in custom-token sign-in results · New Require PASSWORD_RESET action codes when checking reset codes · New Refresh the ID token before revoking Apple access · New
What changed in this PR
Expands the JVM Auth port toward Firebase Android SDK compatibility, supporting firebase-kotlin-sdk’s compatibility layer while documenting flows that still require a device or browser.
Changes:
- Aligns public Auth types, credentials, builders, constants, and result metadata with Android.
- Implements email action flows, email-credential linking, user restoration, and Apple token revocation.
- Adds API and emulator tests and updates the documented Auth limitations.
| File | Description |
|---|---|
| src/test/kotlin/FirebaseAuthTest.kt | Updates the photo URL assertion for Uri. |
| src/test/kotlin/FirebaseAuthEmailFlowsTest.kt | Adds emulator coverage for email and account flows. |
| src/test/kotlin/FirebaseAuthApiTest.kt | Tests API shapes, builders, and unsupported flows. |
| src/main/java/com/google/firebase/auth/UserProfileChangeRequest.kt | Exposes profile request and builder getters. |
| src/main/java/com/google/firebase/auth/UserInfo.kt | Adds the Android-style interface and provider implementation. |
| src/main/java/com/google/firebase/auth/TwitterAuthProvider.java | Implements credential creation and provider constants. |
| src/main/java/com/google/firebase/auth/TwitterAuthCredential.java | Adds Twitter token and secret handling. |
| src/main/java/com/google/firebase/auth/Stubs.kt | Replaces moved stubs with settings and query implementations. |
| src/main/java/com/google/firebase/auth/PhoneAuthProvider.kt | Adds Kotlin replacement and verification failure callbacks. |
| src/main/java/com/google/firebase/auth/PhoneAuthProvider.java | Removes the replaced Java implementation. |
| src/main/java/com/google/firebase/auth/PhoneAuthOptions.kt | Adds phone verification options and builder. |
| src/main/java/com/google/firebase/auth/PhoneAuthCredential.kt | Extracts phone credentials and exposes the SMS code. |
| src/main/java/com/google/firebase/auth/OAuthProvider.java | Aligns inheritance and adds builder accessors. |
| src/main/java/com/google/firebase/auth/OAuthCredentialImpl.java | Adds the package-private OAuth implementation. |
| src/main/java/com/google/firebase/auth/OAuthCredential.java | Converts OAuth credentials to an abstract API. |
| src/main/java/com/google/firebase/auth/MultiFactor.kt | Adds multi-factor types and unsupported-operation results. |
| src/main/java/com/google/firebase/auth/GoogleAuthCredential.java | Adapts Google credentials to the revised base class. |
| src/main/java/com/google/firebase/auth/GithubAuthProvider.java | Implements GitHub credential creation and constants. |
| src/main/java/com/google/firebase/auth/GithubAuthCredential.java | Adds GitHub access-token credentials. |
| src/main/java/com/google/firebase/auth/FirebaseUser.kt | Aligns user properties and adds account operations. |
| src/main/java/com/google/firebase/auth/FirebaseAuthWeakPasswordException.kt | Exposes the password rejection reason. |
| src/main/java/com/google/firebase/auth/FirebaseAuthUserCollisionException.kt | Adds collision email and credential details. |
| src/main/java/com/google/firebase/auth/FirebaseAuthSettings.java | Defines Android-compatible test settings. |
| src/main/java/com/google/firebase/auth/FirebaseAuthProvider.java | Adds the Firebase provider identifier. |
| src/main/java/com/google/firebase/auth/FirebaseAuthMultiFactorException.kt | Adds resolver-bearing exceptions. |
| src/main/java/com/google/firebase/auth/FirebaseAuthMissingActivityForRecaptchaException.kt | Adds the missing-Activity exception type. |
| src/main/java/com/google/firebase/auth/FirebaseAuth.kt | Implements Auth flows, settings, and result handling. |
| src/main/java/com/google/firebase/auth/FederatedAuthProvider.java | Adds the federated provider base class. |
| src/main/java/com/google/firebase/auth/FacebookAuthProvider.java | Implements Facebook credential creation and constants. |
| src/main/java/com/google/firebase/auth/FacebookAuthCredential.java | Adds Facebook access-token credentials. |
| src/main/java/com/google/firebase/auth/EmailAuthProvider.java | Implements password and email-link credential factories. |
| src/main/java/com/google/firebase/auth/EmailAuthCredential.java | Represents password and email-link credentials. |
| src/main/java/com/google/firebase/auth/AuthResultImpl.kt | Parses additional user information and OAuth credentials. |
| src/main/java/com/google/firebase/auth/AuthResult.java | Adds additional information and credential accessors. |
| src/main/java/com/google/firebase/auth/AuthCredential.java | Refactors credential accessors and request serialization. |
| src/main/java/com/google/firebase/auth/AdditionalUserInfo.java | Defines supplementary sign-in metadata. |
| src/main/java/com/google/firebase/auth/ActionCodeUrl.kt | Parses action URLs and wrapped links. |
| src/main/java/com/google/firebase/auth/ActionCodeSettings.kt | Implements action-email settings and request fields. |
| src/main/java/com/google/firebase/auth/ActionCodeResultImpl.kt | Maps action-code responses into result objects. |
| src/main/java/com/google/firebase/auth/ActionCodeResult.java | Adds annotations and the deprecated data accessor. |
| src/main/java/com/google/firebase/auth/ActionCodeMultiFactorInfo.java | Aligns the multi-factor action-info class shape. |
| src/main/java/com/google/firebase/auth/ActionCodeInfo.java | Converts action information into a class. |
| src/main/java/com/google/firebase/auth/ActionCodeEmailInfo.java | Aligns email-change action information. |
| README.md | Updates supported Auth flows and remaining limitations. |
| firebase-debug.log | Adds an emulator execution log. |
Review effort: Balanced
The new operations complete with null as Task<Void>, as the Android SDK's do, and verifyBeforeUpdateEmail joins them through sendOobCode, so the locale header reaches every action email. An action sent for a user, a phone number link and an Apple token revocation first refresh the user's ID token when it has expired. Linking a password credential to an account that already has a password provider fails with ERROR_PROVIDER_ALREADY_LINKED instead of replacing the password, an email-link credential is only created from a sign-in link, verifyPasswordResetCode rejects codes of other actions, updateCurrentUser rejects a user whose token was issued for another project, signInWithCustomToken keeps the sign-in's additional user info, and AuthResult no longer renders the user, whose string form carries its tokens.
The tests initialise their app as fir-java-sdk while the emulator ran as my-firebase-project, which it warned about on every request. The ID tokens it issued carried its own project as audience, so updateCurrentUser's project check rejected them, and the action codes it recorded were listed under its own project, so the email-flow tests found none. The emulator now runs as the tests' project, as it does locally.
nbransby
commented
Oct 31, 2026
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical defects can overwrite an existing password during linking and silently route tenant-selected authentication to the project-level user pool.
11 open issues
Prevent linking a password to an account that already has one · New Apply tenantId to auth requests or reject unsupported values · New Preserve reverted factor details in action-code results · New Expose ActionCodeSettings getters as Kotlin properties · New Require apiKey when parsing action-code links · New Fall back to provider profile fields for the username · New Refresh email and verification state when reloading a user · New Map action-code failures to the expected exception types · New Refresh the ID token before linking a phone number · New Expose exception fields as Kotlin properties · New Add MultiFactorInfo.toJson() to the public API · New
10 resolved since last review
Validate token audience before persisting a signed-in user Reject linking a password provider that's already linked Return null from Void operations to avoid Kotlin Unit casts Redact session credentials from AuthResult.toString() Refresh the ID token before revoking Apple access Require PASSWORD_RESET action codes when checking reset codes Preserve additional user info in custom-token sign-in results Refresh the ID token before sending verification email Include the Firebase locale header in action-email requests Reject non-sign-in action codes for email-link sign-in
Review effort: Max
|
|
||
| internal fun <T> unsupportedTask(message: String): Task<T> = Tasks.forException(UnsupportedOperationException(message)) | ||
|
|
||
| abstract class MultiFactorInfo { |
reload refreshes the profile after the token, so a verified or changed email shows on the current user, and the account lookup also refreshes the phone number, verification state and providers. Linking refreshes the user's ID token first, as the other user actions do, which a token that is not a JWT (a test double's) now survives. Invalid and expired action codes arrive as FirebaseAuthActionCodeException and a weak password as FirebaseAuthWeakPasswordException with the server's reason, keeping the server's codes. An action link needs its apiKey to parse, as on Android, a reverted second factor reports the factor through ActionCodeMultiFactorInfo, and the username falls back to the provider profile's login or screen_name. ActionCodeSettings and the exception details are Kotlin properties behind the Android getter names, so Kotlin written for Android reads them the same way. Setting a tenant throws, since the port signs in to the default tenant only. The emulator's debug log left in the tree is removed and ignored.
This was referenced Oct 31, 2026
Merged
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.


Adds every public Auth class and member the Firebase Android SDK declares and this port lacked, and aligns the four places where the port's shape differed, so that code written against the Android SDK compiles and links against this one. The motivation is firebase-kotlin-sdk's
com.google.firebase.authcompatibility layer (GitLiveApp/firebase-kotlin-sdk#890), whose header stubs are verified against this port on the JVM: against 0.7.0 that verification tolerates 91 missing members and the layer reaches four members by reflection; against this branch it passes with an empty exclusion list and the reflection can go.Shape changes (breaking for callers of the old shapes)
FirebaseUser.getPhotoUrl()returns anandroid.net.Urirather than aString, as on Android (photoUrl.toString()gives the old value).UserInfois the Android interface (withisEmailVerified) andFirebaseUserimplements it;providerDataholds an internal implementation.ActionCodeInfois a class with a protectedemail,ActionCodeEmailInfoandActionCodeMultiFactorInfoabstract classes, as on Android, instead of interfaces.OAuthCredentialis the Android abstract class (getAccessToken,getIdToken,getSecret) over a package-private implementation;OAuthProviderextends the newFederatedAuthProvider.AuthResultgainsgetAdditionalUserInfo()andgetCredential(), so it is no longer a single-method interface; both are filled from the sign-in response (isNewUser,providerId,rawUserInfo,screenNameor the profile'slogin/screen_name, the returned OAuth tokens).MultiFactorInfo,MultiFactorAssertion,MultiFactorandMultiFactorResolverare abstract, as on Android;FirebaseAuthMultiFactorExceptiontakes its resolver;PhoneAuthProvideris Kotlin with the same Java-visible API plus the staticverifyPhoneNumber(PhoneAuthOptions).UserProfileChangeRequestexposesgetDisplayName()andgetPhotoUri(), and itsBuilderthe same getters.FirebaseUser.verifyBeforeUpdateEmailand the new operations returnTask<Void>completing with null, as on Android (updateEmail,updateProfileandupdatePasswordkeep theirTask<Unit>).FirebaseUser.reload()refreshes the profile as well as the token, so a verified or changed email shows on the current user; the account lookup also refreshes the phone number, verification state and providers.FirebaseAuthActionCodeExceptionand a weak password asFirebaseAuthWeakPasswordExceptioncarrying the server's reason; the server's error codes are kept as before.Additions
PROVIDER_IDand sign-in method constants onEmailAuthProvider,FacebookAuthProvider,GithubAuthProvider,TwitterAuthProvider,PhoneAuthProvider;FirebaseAuthProvider; the credential classesEmailAuthCredential(a password or a sign-in link),FacebookAuthCredential,GithubAuthCredential,TwitterAuthCredential(with its token secret);AuthCredentialkeeps its Identity Toolkit post body behind package-private accessors.signInWithCredentialandlinkWithCredentialaccept an email credential: a password signs in withverifyPasswordor links throughaccounts:update(refused withERROR_PROVIDER_ALREADY_LINKEDwhen the account has a password already), a link throughaccounts:signInWithEmailLink; an email-link credential is only created from a sign-in link.ActionCodeSettingsis implemented (builder, Kotlin properties behind the Android getter names,setLinkDomain, the deprecated dynamic link domain) and its fields travel with every action email;ActionCodeUrl.parseLinkreads an action link with anapiKey,oobCodeandmode, as on Android, unwrapping a Dynamic Link;ActionCodeResultgains the deprecatedgetDataand its annotation types,checkActionCodereturns one, and a reverted second factor reports its factor throughActionCodeMultiFactorInfo.FirebaseAuth:sendPasswordResetEmail(both forms),sendSignInLinkToEmail,signInWithEmailLink,isSignInWithEmailLink,checkActionCode,verifyPasswordResetCode(rejects codes of other actions),confirmPasswordReset,applyActionCode,fetchSignInMethodsForEmail,updateCurrentUser(rejects a user of another project),revokeAccessToken(Apple tokens,accounts:revokeToken),getLanguageCode/setLanguageCode(sent asX-Firebase-Localewith every action email),useAppLanguage,getTenantId/setTenantId(setting a tenant throws: the port signs in to the default tenant only),getCustomAuthDomain/setCustomAuthDomain,getFirebaseAuthSettings,getPendingAuthResult(always null),initializeRecaptchaConfig(a completed task),startActivityForSignInWithProvider(fails: no Activity on the JVM). An action sent for a signed-in user, a credential link and a token revocation refresh the user's ID token first when it has expired;signInWithCustomTokenkeeps the sign-in's additional user info through the account lookup.FirebaseUser:sendEmailVerification(both forms),updatePhoneNumber(PhoneAuthCredential)(links the verified number),verifyBeforeUpdateEmail(String),getTenantId,getMultiFactor, the twostartActivityFor…members (fail).PhoneAuthOptionsand itsBuilder;PhoneAuthProvider.verifyPhoneNumber(PhoneAuthOptions)reports to the callbacks that the JVM cannot verify a number;PhoneAuthCredential.getSmsCode.PhoneMultiFactorInfo,TotpMultiFactorInfo,PhoneMultiFactorAssertion,TotpMultiFactorAssertion,PhoneMultiFactorGenerator,TotpMultiFactorGenerator,TotpSecret,MultiFactorInfo.FACTOR_ID_KEY; enrolment fails withUnsupportedOperationException.MultiFactorInfo.toJson()is not mirrored: it returnsorg.json.JSONObject, an Android type the compatibility layer treats as platform-only.FirebaseAuthSettings,FirebaseAuthMissingActivityForRecaptchaException,FirebaseAuthUserCollisionException.email/updatedCredential,FirebaseAuthWeakPasswordException(code, message, reason)andreason,FirebaseAuthMultiFactorException.resolver, all Kotlin properties behind the Android getters.AuthResult's string form names the user rather than rendering it, since the user's carries its tokens.Verification
FirebaseAuthApiTestcovers the shapes, constants, builders and credential types without a server;FirebaseAuthEmailFlowsTestruns password reset, email-link sign-in, email verification observed throughreload(), email-credential linking (including the already-linked refusal),updateCurrentUserand the exception types for an invalid code and a weak password against the Auth emulator, reading the codes it would have emailed from its REST API. The existing Auth and credential tests pass (one assertion now comparesphotoUrl.toString()). The CI emulator now runs as the tests' project,fir-java-sdk, so the tokens and codes it issues belong to the project the tests use.api/jvm/firebase-java-sdk-missing.txtemptied.reauthenticate,unlinkandupdatePasswordremain unimplemented.