Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Make fields from TokenInfo publicly available #920

Merged
merged 1 commit into from
Mar 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading