Skip to content

Commit

Permalink
Add token storage in BoxAuthenticator and getUserId method in BoxCred…
Browse files Browse the repository at this point in the history
…ential
  • Loading branch information
iammajid committed May 27, 2024
1 parent 23b077e commit 17de27a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/CryptomatorCloudAccess/Box/BoxAuthenticator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public enum BoxAuthenticator {
throw BoxAuthenticatorError.invalidContext
}

let config = OAuthConfig(clientId: BoxSetup.constants.clientId, clientSecret: BoxSetup.constants.clientSecret)
let config = OAuthConfig(clientId: BoxSetup.constants.clientId, clientSecret: BoxSetup.constants.clientSecret, tokenStorage: tokenStorage)
let oauth = BoxOAuth(config: config)

// Run the login flow and store the access token using tokenStorage
Expand Down
15 changes: 15 additions & 0 deletions Sources/CryptomatorCloudAccess/Box/BoxCredential.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,19 @@ public class BoxCredential {

return pendingPromise
}

public func getUserId() -> Promise<String> {
let pendingPromise = Promise<String>.pending()

_Concurrency.Task {
do {
let user = try await client.users.getUserMe()
pendingPromise.fulfill(user.id)
} catch {
pendingPromise.reject(error)
}
}

return pendingPromise
}
}

0 comments on commit 17de27a

Please sign in to comment.