OAuth2Token class

An OAuth2 access token + refresh token + expiry.

Constructors

OAuth2Token({required String accessToken, required String refreshToken, required DateTime expiresAt, String tokenType = 'Bearer', String? scope})
Creates an OAuth2Token.
OAuth2Token.fromJson(Map<String, Object?> json)
Parses an OAuth2Token from a JSON response (the standard OAuth2 token endpoint format).
factory
OAuth2Token.nonExpiring({required String accessToken, required String refreshToken})
Convenience constructor with null expiry (means "never expires"). Useful for tests / for tokens that don't have an expiry claim.
factory

Properties

accessToken → String
The access token.
final
authorizationHeader → String
The Authorization header value (e.g. Bearer abc123).
no setter
expiresAt → DateTime
When the access token expires.
final
hashCode → int
The hash code for this object.
no setterinherited
refreshToken → String
The refresh token.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
scope → String?
The scope (optional).
final
tokenType → String
The token type (default Bearer).
final

Methods

isExpired({Duration buffer = const Duration(seconds: 30)}) → bool
true if the access token has expired (or is about to — within buffer).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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