Providers
Choosing a provider
Which provider fits how your users sign in.
A provider answers one question: how does the user prove who they are, and who issues the tokens your API accepts?
| Your users sign in with | Tokens issued by | Use |
|---|---|---|
| Email or username and password, against your API | Your API | CredentialsProvider |
| An OAuth 2.0 / OIDC server you control (Keycloak, Auth0, Zitadel, Okta, Cognito, Entra ID) | That server | OAuth2Provider |
| A social login whose tokens your API does not accept (GitHub, GitLab, Discord, Slack...) | Your API, after your backend runs the OAuth flow | BackendOAuthProvider |
| Google, with the native account picker | Your API, after it verifies Google's ID token | GoogleProvider.withExchange |
| Apple, with the native sheet | Your API, after it verifies Apple's identity token | AppleProvider.withExchange |
| Magic links, OTP, passkeys, anything else | Your API | A custom provider |
An app can register several providers at once; each session remembers which one created it.
final authyra = await Authyra.initialize(
storage: SecureAuthStorage(),
providers: [
apiProvider, // id: 'api'
GoogleProvider.withExchange(exchange: exchangeGoogle), // id: 'google'
AppleProvider.withExchange(exchange: exchangeApple), // id: 'apple'
],
);
await authyra.signIn('google');
Identity only
GoogleProvider() and AppleProvider() without an exchange sign the user in with an identity-only session: no tokens, the provider's credential in providerData. Use it when another SDK (Firebase, Supabase) consumes that credential, or when the app needs to know who the user is but calls no API on their behalf.