Inspect the provider involved in a sign-in callback
Callback handling
Auth.js · Type Alias
Account is the Auth.js core type for information about the provider used during authentication. It also includes TokenSet fields for provider-returned token data.
Account describes the provider-specific connection used for authentication. It includes provider identity, provider type, and token-related values inherited from TokenSet, with some fields varying by provider.
type Account = Partial<TokenEndpointResponse> & {
provider: string
type: ProviderType
providerAccountId: string
...
}An Account object describing the authentication provider connection and its provider-specific token or identity data.
import type { Account } from "@auth/core/types"
export function providerId(account: Account): string {
return account.provider
}Accepts an Auth.js account and returns the identifier of the provider associated with it.
Callback handling
Token persistence
Provider-specific logic
Account represents information about the provider used for a sign-in. It also extends TokenSet, so it can carry tokens returned by an OAuth provider.
Follow-up: How would you distinguish an OAuth account from an email account? Use the account's provider and type fields; the type identifies the provider category.
The provider field identifies the configured provider, such as Google. The type field uses ProviderType and identifies the provider category.
Follow-up: What additional value can the provider field have for credentials authentication? It identifies the configured credentials provider, while the account identifier is provider-specific.
Account can contain token information because it extends TokenSet. The exact account identifier and related values depend on the provider type.
Follow-up: Why should persistence code account for provider differences? OAuth, email, and credentials providers supply different identity and token data.
TokenSetProviderTypeAdapterAccountUserProfile