Skip to content

fix(auth): import an implicit deeplink session before calling onSessionSuccess - #1450

Open
AndroidPoet wants to merge 1 commit into
supabase:masterfrom
AndroidPoet:test/auth-apple-handle-deeplinks
Open

AndroidPoet wants to merge 1 commit into
supabase:masterfrom
AndroidPoet:test/auth-apple-handle-deeplinks

Conversation

@AndroidPoet

Copy link
Copy Markdown
Contributor

What

Part of #1105 (the Apple half).

With the implicit flow, handleDeeplinks calls onSessionSuccess before the session is imported. parseFragmentAndImportSession calls onFinish and only then importSession, so inside the callback currentSessionOrNull() is still null and sessionStatus is not yet Authenticated. An app that navigates or reads the session in onSessionSuccess sees no session. The PKCE flow already imports first and then calls the callback. This affects both the Android and the Apple handleDeeplinks.

Fix

Call importSession before onFinish in parseFragmentAndImportSession.

Tests

New Auth/src/appleTest/kotlin/HandleDeeplinksTest.apple.kt drives the Apple handleDeeplinks(NSURL) against the mocked client:

  • PKCE: the code and stored verifier are sent to /token?grant_type=pkce, and the session is stored when onSessionSuccess runs.
  • PKCE without a stored verifier: onError gets the IllegalArgumentException and no session is stored.
  • PKCE with error, error_code and error_description in the URL: an AuthEvent.OtpError is emitted and no request is sent.
  • Implicit: the fragment session is imported after /user, and is current when onSessionSuccess runs. This one fails without the fix.
  • A different scheme or host is ignored.

All 201 Auth macosArm64 tests and 196 Auth JVM tests pass, and detekt is clean. The Android half of #1105 needs Robolectric, so it is not in this PR.

No public API change.

jan-tennert
jan-tennert previously approved these changes Nov 1, 2026
@jan-tennert
jan-tennert dismissed their stale review November 1, 2026 23:24

Will revisit tomorrow

This branch has not been deployed

No deployments
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.

2 participants