Skip to content

Commit

Permalink
feat: Make fields from TokenInfo publicly available (#920)
Browse files Browse the repository at this point in the history
  • Loading branch information
arjankowski authored Mar 8, 2024
1 parent 36f464c commit eb26f47
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions Sources/Responses/TokenInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ public class TokenInfo: Codable {
case issuedTokenType
}

var accessToken: String
var refreshToken: String?
var expiresIn: TimeInterval
var tokenType: String
/// The access token
public let accessToken: String
/// The refresh token for this access token, which can be used to request a new access token when the current one expires
public let refreshToken: String?
/// The time in seconds by which this token will expire
public let expiresIn: TimeInterval
/// The type of access token returned
public let tokenType: String
private var restrictedTo: [[String: AnyCodable]]?
let expiresAt: Date
var issuedTokenType: String?

var restrictedToObjects: [[String: Any]] {
/// Expiration date of the token
public let expiresAt: Date
/// The type of downscoped access token returned. This is only returned if an access token has been downscoped
public let issuedTokenType: String?
/// The permissions that this access token permits, providing a list of resources (files, folders, etc) and the scopes permitted for each of those resources
public var restrictedToObjects: [[String: Any]] {
guard let unwrappedRestrictedTo = restrictedTo else {
return []
}
Expand Down Expand Up @@ -71,6 +77,7 @@ public class TokenInfo: Codable {
self.expiresIn = expiresIn
self.tokenType = tokenType
expiresAt = Date(timeInterval: expiresIn, since: Date())
issuedTokenType = nil
}

/// Initializer.
Expand All @@ -84,6 +91,7 @@ public class TokenInfo: Codable {
self.expiresIn = expiresIn
tokenType = "bearer"
expiresAt = Date(timeInterval: expiresIn, since: Date())
issuedTokenType = nil
}
}

Expand Down

0 comments on commit eb26f47

Please sign in to comment.