Skip to content

Instantly share code, notes, and snippets.

@albertodebortoli
Created December 3, 2019 11:08
Show Gist options
  • Save albertodebortoli/237fdd86dfd2e0711ec78eb02874aa43 to your computer and use it in GitHub Desktop.
Save albertodebortoli/237fdd86dfd2e0711ec78eb02874aa43 to your computer and use it in GitHub Desktop.
used by 'Lessons learned from handling JWT on mobile' article on Medium
class AuthorizationValueProvider {
private let authenticationInfoStore: AuthenticationInfoStorage
private let tokenRefreshAPI: TokenRefreshing
private let queue = DispatchQueue(label: <#label#>, qos: .userInteractive)
private let semaphore = DispatchSemaphore(value: 1)
init(tokenRefreshAPI: TokenRefreshing,
authenticationInfoStore: AuthenticationInfoStorage) {
self.tokenRefreshAPI = tokenRefreshAPI
self.authenticationInfoStore = authenticationInfoStore
}
func getValidUserAuthorization(completion: @escaping (Result<AuthorizationValue, Error>) -> Void) {
queue.async {
self.getValidUserAuthorizationInMutualExclusion(completion: completion)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment