fix(api,swift): accept native iOS client IDs for Google and Apple sign-in - #2638
Merged
Conversation
Native Google Sign-In on iOS mints an ID token with the iOS OAuth client ID as its aud claim, not the web client ID Better Auth was validating against — causing "Invalid id token" on every Swift Google sign-in. Better Auth's google provider accepts an array of client IDs, so pass both.
The Swift iOS app is a separate Xcode target (com.andrewbierman.packrat.swift) from the Expo app's EAS build variants, so its Apple ID token's aud claim never matched Better Auth's configured audience list — sign-in failed with a generic "content could not be loaded" error in the Swift UI. Add APPLE_SWIFT_CLIENT_ID to the accepted audiences, mirroring the iOS Google client ID fix.
PackRat-iOS.entitlements had an empty dict, so the iOS app never declared the com.apple.developer.applesignin capability even though it's wired into the Xcode project's provisioning. Native Apple Sign-In needs this entitlement present for a device build to be authorized.
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughAdds iOS Apple Sign-In entitlement support and configures API Google and Apple OAuth validation for native client IDs. ChangesNative OAuth configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
Coverage Report for packages/analytics (./packages/analytics)
File CoverageNo changed files found. |
Contributor
Coverage Report for packages/utils (./packages/utils)
File CoverageNo changed files found. |
Contributor
Coverage Report for packages/overpass (./packages/overpass)
File CoverageNo changed files found. |
Contributor
Coverage Report for packages/units (./packages/units)
File CoverageNo changed files found. |
Contributor
Coverage Report for packages/api (./packages/api)
File CoverageNo changed files found. |
Contributor
Coverage Report for apps/expo (./apps/expo)
File CoverageNo changed files found. |
Contributor
Coverage Report for packages/mcp (./packages/mcp)
File CoverageNo changed files found. |
10 tasks
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.
Description
Native sign-in from the Swift iOS app was failing with "Invalid id token" for both Google and Apple providers.
audclaim differs from the web client ID Better Auth was validating against.com.andrewbierman.packrat.swift) from the Expo app's EAS build variants, so its Apple ID token'saudclaim never matched Better Auth's configured audience list. Its entitlements file also had an empty<dict/>, missing thecom.apple.developer.applesignincapability.Type of change
Area(s) affected
apps/swift, not listed above but affected)packages/api)Testing
bun check-types,bun check(scoped to changed files),bun test:api:unit(619 tests) all passPre-merge checklist
bun format && bun lintpasses with no errorsbun check-typespasses with no errorsNotes for reviewers
Local testing surfaced a separate infra issue unrelated to this PR's code:
wrangler dev's local sandbox gets a403 Forbiddenfromhttps://appleid.apple.com/auth/keys(Apple's JWKS endpoint), which blocks Apple Sign-In from completing in local dev regardless of this fix. The audience/bundle-ID config was verified correct via debug logging before this was discovered — this fix should still be validated against a deployed (non-local) API environment.Requires deploying these new env vars to staging/prod as Worker secrets:
GOOGLE_IOS_CLIENT_IDAPPLE_SWIFT_CLIENT_ID(value:com.andrewbierman.packrat.swift)Summary by CodeRabbit
New Features
Bug Fixes