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 withTokens issued byUse
Email or username and password, against your APIYour APICredentialsProvider
An OAuth 2.0 / OIDC server you control (Keycloak, Auth0, Zitadel, Okta, Cognito, Entra ID)That serverOAuth2Provider
A social login whose tokens your API does not accept (GitHub, GitLab, Discord, Slack...)Your API, after your backend runs the OAuth flowBackendOAuthProvider
Google, with the native account pickerYour API, after it verifies Google's ID tokenGoogleProvider.withExchange
Apple, with the native sheetYour API, after it verifies Apple's identity tokenAppleProvider.withExchange
Magic links, OTP, passkeys, anything elseYour APIA 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.

Copyright © 2026