OAuthProvider<TProfile extends Object> class

OAuth 2.0 provider configuration.

Required fields

  • id and name are visible to clients.
  • authorizationEndpoint and tokenEndpoint power the OAuth handshake.
  • profile maps provider-specific profile data into an AuthUser.

Typed profiles

  • profileParser converts a raw profile map into a typed profile.
  • profileSerializer converts the typed profile back into a map for metadata storage.

Optional hooks

  • onStateGenerated lets you persist extra state tied to the OAuth flow.
  • onProfile lets you override the mapped user.
  • profileRequest can enrich the profile (for example, extra API calls).
Inheritance

Constructors

OAuthProvider({required String id, required String name, required String clientId, required String clientSecret, required Uri authorizationEndpoint, required Uri tokenEndpoint, required AuthProfileMapper<TProfile> profile, required String redirectUri, AuthProviderType type = AuthProviderType.oauth, Uri? userInfoEndpoint, Uri? oidcIssuer, Uri? oidcJwksUri, List<String> oidcAlgorithms = const <String>['RS256'], Duration requestTimeout = const Duration(seconds: 10), OAuthUserInfoRequest? userInfoRequest, List<String> scopes = const <String>[], Map<String, String> authorizationParams = const <String, String>{}, Map<String, String> tokenParams = const <String, String>{}, bool usePkce = true, bool useBasicAuth = true, OAuthProfileParser<TProfile>? profileParser, OAuthProfileSerializer<TProfile>? profileSerializer, OAuthStateCallback<TProfile>? onStateGenerated, OAuthProfileCallback<TProfile>? onProfile, OAuthProfileRequest<TProfile>? profileRequest})
Creates an OAuth or OIDC provider configuration.

Properties

authorizationEndpoint → Uri
Authorization endpoint for the provider.
final
authorizationParams → Map<String, String>
Extra authorization parameters appended to the request.
final
clientId → String
OAuth client identifier.
final
clientSecret → String
OAuth client secret.
final
hashCode → int
The hash code for this object.
no setterinherited
id → String
Provider identifier used in callback routes.
finalinherited
name → String
Human-readable provider name.
finalinherited
oidcAlgorithms → List<String>
Signature algorithms accepted for OIDC ID tokens.
final
oidcIssuer → Uri?
Issuer used to validate an OIDC ID token.
final
oidcJwksUri → Uri?
JWKS endpoint used to validate an OIDC ID token.
final
onProfile → OAuthProfileCallback<TProfile>?
Optional hook for profile overrides.
final
onStateGenerated → OAuthStateCallback<TProfile>?
Optional hook for custom state handling.
final
profile → AuthProfileMapper<TProfile>
Maps the provider profile payload into an AuthUser.
final
profileParser → OAuthProfileParser<TProfile>?
Converts raw profile payloads to typed profiles.
final
profileRequest → OAuthProfileRequest<TProfile>?
Optional hook to enrich profile payloads with extra API calls.
final
profileSerializer → OAuthProfileSerializer<TProfile>?
Converts typed profiles to JSON-friendly maps.
final
redirectUri → String
Redirect URI registered with the provider.
final
requestTimeout → Duration
Timeout applied to provider token and user-info requests.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scopes → List<String>
OAuth scopes to request.
final
tokenEndpoint → Uri
Token exchange endpoint for the provider.
final
tokenParams → Map<String, String>
Extra token request parameters appended to the exchange.
final
type → AuthProviderType
Provider category.
finalinherited
useBasicAuth → bool
Uses HTTP basic auth for the token exchange.
final
usePkce → bool
Enables PKCE for the authorization code flow.
final
userInfoEndpoint → Uri?
Userinfo endpoint (optional if ID token contains claims).
final
userInfoRequest → OAuthUserInfoRequest?
Custom userinfo request callback for providers that require non-standard userinfo fetching (e.g., POST instead of GET).
final

Methods

authenticationMethodInventory(AuthStore store) → AuthAuthenticationMethodInventoryContributor?
Builds this provider's authoritative usable-method inventory.
inherited
enrichProfile(AuthContext context, OAuthTokenResponse token, Client httpClient, TProfile profile) → FutureOr<TProfile>
Runs the optional profile enrichment hook.
mapProfile(TProfile profile) → AuthUser
Maps the typed profile into an AuthUser.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
overrideProfile(AuthContext context, TProfile profile) → FutureOr<AuthUser?>
Runs the optional profile override hook.
parseProfile(Map<String, dynamic> profile) → TProfile
Parses the raw profile response into the typed profile.
redacted() → AuthProvider
Creates a provider metadata projection safe for events and audit logs.
inherited
serializeProfile(TProfile profile) → Map<String, dynamic>
Serializes the typed profile into a JSON-friendly map.
toJson() → Map<String, dynamic>
Summary payload used by /auth/providers.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited