Account Interface
TheAccount interface represents a linked OAuth provider account. Users can have multiple accounts linked to their profile (e.g., Google, GitHub, Facebook).
Unique identifier for the account record
The ID of the user this account is linked to. References
User.id.The OAuth provider identifier (e.g., “google”, “github”, “facebook”)
The unique account identifier from the OAuth provider. This is the user’s ID in the provider’s system.
The OAuth access token for this account. Used to make API requests to the provider on behalf of the user.
The OAuth refresh token. Used to obtain new access tokens when they expire.
Timestamp when the access token expires. Used to determine when to refresh the token.
Timestamp when the account was linked
OAuth Account Linking
Accounts are automatically created when users sign in with OAuth providers. Arraf Auth supports linking multiple OAuth providers to a single user account.How Account Linking Works
-
First Sign-In: When a user signs in with an OAuth provider for the first time, Arraf Auth creates both a
Userand anAccountrecord. - Matching Existing Users: If a user with the same verified email already exists, the new OAuth account is linked to the existing user.
- Multiple Providers: Users can link multiple OAuth providers (Google, GitHub, etc.) to the same account for flexible authentication.
Usage Example
Access tokens and refresh tokens are sensitive credentials. Ensure your database is properly secured and consider encrypting these fields.
Account linking is automatic when users sign in with OAuth providers. If a user signs in with Google and later with GitHub using the same email, both accounts will be linked to the same User record.