Skip to content

Conversation

grdsdev
Copy link
Contributor

@grdsdev grdsdev commented Aug 8, 2025

What kind of change does this PR introduce?

Feature - This PR adds a new linkIdentityWithIdToken method to the GoTrue client for linking identities using ID tokens, and refactors the existing signInWithIdToken method to share common code.

What is the current behavior?

Currently, users can only sign in with ID tokens using the signInWithIdToken method, but there's no way to link additional identities to an existing user account using ID tokens. The signInWithIdToken and any potential identity linking methods would have duplicate code.

What is the new behavior?

  • New Method: Added linkIdentityWithIdToken method that allows linking identities to existing users using ID tokens
  • Code Refactoring: Extracted common logic into _signInWithIdToken helper method to eliminate code duplication
  • Backward Compatibility: signInWithIdToken maintains the exact same API and behavior
  • Shared Logic: Both methods now share validation, HTTP request handling, and session management logic

Key Features:

  • Supports the same OAuth providers as signInWithIdToken (google, apple, kakao, keycloak)
  • Sends link_identity: true flag when linking identities
  • Proper error handling and session management
  • Comprehensive documentation

Additional context

This implementation follows the same pattern as the existing signInWithIdToken method but adds the link_identity flag for identity linking functionality. The refactoring improves code maintainability by eliminating duplication while preserving all existing functionality.

The changes are minimal and focused, affecting only the GoTrue client authentication methods without any breaking changes to the public API.

Reference PR: supabase/auth-js#1096

Close #1111
Close #1200

Copy link
Member

@dshukertjr dshukertjr left a comment

Choose a reason for hiding this comment

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

Huge!

Copy link
Collaborator

@Vinzent03 Vinzent03 left a comment

Choose a reason for hiding this comment

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

LGTM.

@grdsdev
Copy link
Contributor Author

grdsdev commented Aug 11, 2025

Thanks for the approval. However, this isn’t deployed to production yet. I’ll merge it once it’s deployed.

@erichin
Copy link

erichin commented Aug 26, 2025

@grdsdev @dshukertjr
Thank you for adding this feature. Could you let me know when it will be released for Flutter?
Without this feature, our application cannot pass the Apple review.

- Add linkIdentityWithIdToken method to link identities using ID tokens
- Support OAuth providers with ID token verification
- Include nonce and access token validation for enhanced security
- Emit userUpdated event when identity is successfully linked

Closes CLIBS-282
@grdsdev grdsdev force-pushed the guilherme/clibs-282-supabase-flutter-implement-linkidentity-with-oidc branch from 0fd1c34 to 2c0819c Compare September 15, 2025 13:48
@coveralls
Copy link

coveralls commented Sep 15, 2025

Pull Request Test Coverage Report for Build 17735587008

Details

  • 0 of 15 (0.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.3%) to 80.42%

Changes Missing Coverage Covered Lines Changed/Added Lines %
packages/gotrue/lib/src/gotrue_client.dart 0 15 0.0%
Totals Coverage Status
Change from base Build 17477396007: -0.3%
Covered Lines: 3105
Relevant Lines: 3861

💛 - Coveralls

@grdsdev grdsdev marked this pull request as ready for review September 15, 2025 13:57
@grdsdev grdsdev merged commit 53a2427 into main Sep 15, 2025
15 checks passed
@grdsdev grdsdev deleted the guilherme/clibs-282-supabase-flutter-implement-linkidentity-with-oidc branch September 15, 2025 14:37
@jerdmeyer
Copy link

Is this feature available for use in the @supabase/supabase-js client? I would love to use it in my expo react native app on iOS to support users experiencing the app first without enforcing sign in :)

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.

Apple app review rejecting submission due to apple signup/in process. (linkidentity) Manual linking with native flow (ID token) for google, apple
6 participants