OAuth2User - daneden/Twift GitHub Wiki

OAuth2User

An OAuth 2.0 user authentication object

public struct OAuth2User: Codable 

Inheritance

Codable

Initializers

init(from:)

Initialises a new OAuth2User object from a decoder

public init(from decoder: Decoder) throws 

init(accessToken:refreshToken:clientId:expiresIn:scope:)

Convenience initialiser for creating a new OAuth2User from known values

public init(accessToken: String, refreshToken: String? = nil, clientId: String? = nil, expiresIn: TimeInterval = 7200, scope: Set<OAuth2Scope>) 

Properties

clientId

The client ID for which this OAuth token is valid

public var clientId: String?

accessToken

The current access token, valid until expiresAt

public var accessToken: String

refreshToken

The refresh token, used to renew authentication once the accessToken has expired. Only available when scope includes offlineAccess.

public var refreshToken: String?

expiresAt

The date at which the accessToken expires.

public var expiresAt: Date

scope

The scope of permissions for this access token.

public var scope: Set<OAuth2Scope>

expired

Whether or not the access token has expired (i.e. whether expiresAt is in the past).

public var expired: Bool 

Methods

encode(to:)

Encodes the OAuth2User instance to an encoder

public func encode(to encoder: Encoder) throws