Overview
Auth method linking enables users to associate multiple authentication methods with a single embedded wallet account. This allows users to sign in using different methods (email, SMS, OAuth) while maintaining access to the same wallet and user identity.Ready to get started? Jump to implementation examples or check out the React Hooks documentation for detailed hook usage.
Why link authentication methods?
By default, each authentication method creates a separate user identity. For example, if a user signs in with their email and later signs in with their phone number, they would have two different embedded wallets. Auth method linking solves this problem by allowing users to:- Access their wallet using multiple methods: Sign in with email, phone, or social providers interchangeably.
- Meet 2FA requirements: For applications that require 2FA, Embedded Wallets provide a smooth integration.
- Improve account security: Add additional authentication factors as users accumulate more funds.
- Enhance account recovery: Multiple methods provide backup options if one method becomes unavailable.
Important: A user must be signed in before linking additional authentication methods. Users cannot link methods to an unauthenticated session.
Supported authentication methods
You can link any combination of the following authentication methods to a single user account:- Email OTP
- SMS OTP
- All supported OAuth providers
Security features
Auth method linking maintains the same security standards as initial authentication:Verification requirements
Verification requirements
Each additional authentication method must be verified before being linked:
- Email: Requires OTP verification (10-minute expiration).
- SMS: Requires OTP verification (5-minute expiration).
- OAuth providers: Requires successful OAuth flow completion.
Rate limiting
Rate limiting
- Protection against brute force attempts on OTP verification.
- Failed attempts may temporarily lock linking operations.
Device binding
Device binding
- Linked methods maintain the same device binding as the primary authentication.
- Users can access their wallet from up to 5 devices regardless of which linked method they use.
Implementation examples
The examples below use React hooks from
@coinbase/cdp-hooks. For other implementation approaches, see the Implementation Guide.Link an email address
Use theuseLinkEmail hook to link an email address to the currently authenticated user. This follows the same two-step flow as email sign-in: initiate the flow and then verify the OTP.
Link a phone number
Use theuseLinkSms hook to link a phone number to the currently authenticated user. Like email linking, this requires OTP verification.
SMS security considerations:
- SMS authentication is inherently vulnerable to SIM swapping attacks.
- Consider the security implications when allowing SMS as a linked authentication method.
- For high-value accounts, encourage users to link additional non-SMS methods.
Link a Google account
Use theuseLinkGoogle hook to link a Google account to the currently authenticated user. This initiates the OAuth flow for Google authentication.
Link an Apple account
Use theuseLinkApple hook to link an Apple account to the currently authenticated user. This initiates the OAuth flow for Apple authentication.
Link any OAuth provider
Use theuseLinkOAuth hook to link any supported OAuth provider to the currently authenticated user. This provides a unified interface for all OAuth providers.
OAuth authentication support:
- OAuth2 login is currently only supported via web. An upcoming release will add support for React Native.
User experience best practices
When implementing auth method linking, consider these UX recommendations:Progressive security
Progressive security
Prompt users to add additional authentication methods as their account value increases. For example:
- Basic users: Single authentication method.
- Users with funds: Prompt to add a second method.
- High-value accounts: Encourage multiple authentication methods.
Clear communication
Clear communication
- Explain the benefits of linking additional methods before prompting.
- Show which methods are already linked in account settings.
- Provide clear success/error messages during the linking process.
Account recovery
Account recovery
- Position linked methods as a recovery option.
- Encourage users to link at least one additional method for account security.
- Provide clear documentation on how to use linked methods for sign-in.
Onramp integration
Onramp integration
For apps integrating with Coinbase Onramp:
- Inform users they need both email and phone verification for onramp.
- Automatically prompt for the missing method when users attempt to use onramp.
- Provide a seamless flow from authentication to onramp.
Error States
Common errors you may encounter when linking authentication methods:| Error | Description |
|---|---|
METHOD_ALREADY_LINKED | The authentication method is already linked to this or another account. |
ACCOUNT_EXISTS | The intended account to link already belongs to another user. |
What to read next
- Authentication Methods: Learn about available authentication methods
- React Hooks: Comprehensive guide to CDP React hooks
- Onramp Integration: Integrate Coinbase Onramp with linked authentication
- Session Management: Understand how sessions work with linked methods
- Best Practices: Security recommendations for production applications