Token
public struct Token : Codable, Sendable
extension Token: CustomStringConvertible
Struct representing an OIDC token.
-
The access token used for authentication.
Declaration
Swift
public let accessToken: String -
The type of token.
Declaration
Swift
public let tokenType: String? -
The scope of access granted by the token.
Declaration
Swift
public let scope: String? -
The duration of the token’s validity in seconds
Declaration
Swift
public let expiresIn: Int64 -
The refresh token used to obtain a new access token.
Declaration
Swift
public let refreshToken: String? -
The ID token
Declaration
Swift
public let idToken: String? -
The exact timestamp (in seconds since 1970) when the token expires.
Declaration
Swift
public let expiresAt: Int64 -
Initializes a new instance of
Token.Declaration
Swift
public init(accessToken: String, tokenType: String?, scope: String?, expiresIn: Int64, refreshToken: String?, idToken: String?)Parameters
accessTokenThe access token string.
tokenTypeThe type of token.
scopeThe scope of access granted by the token.
expiresInThe duration (in seconds) for which the token is valid.
refreshTokenThe refresh token string (optional).
idTokenThe ID token string (optional).
-
A Boolean value indicating whether the token has expired.
Declaration
Swift
public var isExpired: Bool { get }Return Value
trueif the current time is greater than or equal to the token’s expiry time; otherwise,false. -
Checks if the token will expire within a specified threshold.
Declaration
Swift
public func isExpired(threshold: Int64) -> BoolParameters
thresholdThe threshold duration (in seconds) to check for expiration.
Return Value
trueif the token will expire within the threshold; otherwise,false. -
Decodes a
Tokeninstance from a decoder.Throws
An error if decoding fails.Declaration
Swift
public init(from decoder: Decoder) throwsParameters
decoderThe decoder instance used for decoding.
-
Encodes the
Tokeninstance to an encoder.Throws
An error if encoding fails.Declaration
Swift
public func encode(to encoder: Encoder) throwsParameters
encoderThe encoder instance used for encoding.
-
A textual representation of the
Tokeninstance.Declaration
Swift
public var description: String { get }
View on GitHub