Skip to content

feat(gotrue): Implement linkIdentityWithIdToken method #1206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

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

grdsdev added 2 commits August 8, 2025 08:38
- Add linkIdentityWithIdToken method for linking identities with ID tokens
- Refactor signInWithIdToken and linkIdentityWithIdToken to share common code
- Create _signInWithIdToken helper method to eliminate code duplication
- Maintain backward compatibility with existing signInWithIdToken API
- Add proper documentation and experimental annotation
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.

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.

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