Skip to content

Add GoogleAuthProvider.credential(withIDToken:accessToken:) - #104

Open
vincentborko wants to merge 1 commit into
skiptools:mainfrom
vincentborko:pr/auth-google-provider
Open

vincentborko wants to merge 1 commit into
skiptools:mainfrom
vincentborko:pr/auth-google-provider

Conversation

@vincentborko

@vincentborko vincentborko commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What

SkipFirebaseAuth has no GoogleAuthProvider on the Android side. Only EmailAuthProvider and the generic OAuthProvider are wrapped, so an app that already holds a Google ID token, which is what Credential Manager and Google Identity Services hand out, has nothing to turn it into an AuthCredential. The only route left is Auth.signIn(with: OAuthProvider(providerID: "google.com")), which is startActivityForSignInWithProvider: a browser redirect that takes the user out of the app.

This adds GoogleAuthProvider.credential(withIDToken:accessToken:) and GoogleAuthProvider.id, plus AuthCredential.provider. All three match the iOS API of the same name.

How

credential(withIDToken:accessToken:) wraps com.google.firebase.auth.GoogleAuthProvider.getCredential. An empty accessToken maps to null, because Credential Manager returns an ID token and no access token, and the Android API takes null there.

AuthCredential.provider wraps getProvider(). It earns its place beyond parity: it is the only way to assert the result of a credential builder without a network call, which is what the new test does.

id is spelled out as "google.com" rather than read from GoogleAuthProvider.PROVIDER_ID. The Java constant arrives with an implicitly unwrapped type, and a native SkipFuse consumer then fails to build with '?' does not appear to be a bridged type. The iOS SDK spells the same constant out.

Verification

swift test --filter SkipFirebaseAuthTests, which runs the transpiled tests under Robolectric as well as the Swift ones:

JUNIT TEST PASSED SkipFirebaseAuthTests.testGoogleAuthProviderCredential (2.699)
JUNIT SUITES 1 TESTS 2 PASSED 2 (100.0%) FAILED 0 SKIPPED 0
Executed 3 tests, with 0 failures (0 unexpected) in 64.109 seconds

The new test is not a shape test under if false. Building a Google credential needs no network and no Firebase app, so it runs and asserts on both platforms.

It has been red. With id mutated to "apple.com":

java.lang.AssertionError: google.com != apple.com
Failed tests: skip.firebase.auth.SkipFirebaseAuthTests.testGoogleAuthProviderCredential
Executed 3 tests, with 4 failures (0 unexpected) in 22.574 seconds

Reverted, green again. A counter-mutation outside the change (swapping the two arguments in EmailAuthProvider.credential(withEmail:password:)) stays green, so the test measures the new code rather than the file.

Consumed for real in an app on an Android emulator: tapping the Google button no longer starts a browser. GenericIdpActivity goes from 21 log lines to 0 and Chrome from 6 starts to 0, with a positive control line that stays at 2 in both runs.

Redeeming the ID token against the Firebase backend is verified too, on an emulator with a real Google account signed in: Credential Manager status=ok idTokenLength=1108, and Firebase returns the same UID for that account as the browser-redirect path returns. It was an existing user, not a fresh one: both runs land on identical app data, so the credential built here resolves to the same identity rather than creating a second account. Before each install, the APK was checked for a marker string from the branch under test, with a control string present in both, so each run is known to carry the code it claims.

Not verified

Whether the same holds for an account whose Firebase user was originally created on iOS or on the web. Measured on one account.

Skip Pull Request Checklist:

  • REQUIRED: I have signed the Contributor Agreement
  • REQUIRED: I have tested my change locally with swift test
  • OPTIONAL: I have tested my change on an iOS simulator or device
  • OPTIONAL: I have tested my change on an Android emulator or device

  • AI was used to generate or assist with generating this PR.

Signing in to Firebase with a Google ID token is the documented path on both
platforms, but the Android side of SkipFirebaseAuth had no `GoogleAuthProvider`
at all: only `EmailAuthProvider` and the generic `OAuthProvider`. A Skip app
that gets an ID token from Credential Manager had nothing to hand it to.

`AuthCredential.provider` comes along because it is the only way to assert the
result without a network call, and it matches the iOS property of the same name.

An empty `accessToken` maps to `null`, which is what Credential Manager callers
need: it returns an ID token and no access token.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@cla-bot cla-bot Bot added the cla-signed label Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant