TokenResponse class

Represents an OAuth2 token response from the authorization server.

Contains the access token, optional refresh token, and expiration information. Use isExpired and isExpiringSoon to check token validity.

Constructors

TokenResponse({required String accessToken, String? refreshToken, required int expiresIn, int? refreshExpiresIn, required String tokenType, String? scope, DateTime? issuedAt})
Creates a new TokenResponse.
TokenResponse.fromJson(Map<String, dynamic> json)
Creates a TokenResponse from a JSON map (OAuth2 token endpoint response).
factory

Properties

accessToken String
The access token used for API authentication.
final
expiresIn int
Token lifetime in seconds from issuedAt.
final
hashCode int
The hash code for this object.
no setterinherited
isExpired bool
Returns true if the access token has expired.
no setter
isExpiringSoon bool
Returns true if the access token will expire within 30 seconds.
no setter
issuedAt DateTime
When the token was issued.
final
refreshExpiresIn int?
Refresh token lifetime in seconds, if provided.
final
refreshToken String?
The refresh token used to obtain new access tokens.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scope String?
The granted scopes, space-separated.
final
tokenType String
The token type (typically "Bearer").
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts this token response to a JSON map for serialization.
toString() String
A string representation of this object.
inherited

Operators

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