Hi,
I have working on an iOS application and we want to access user repositories, download it to phone then make some changes and push it back. All of those were working with a hard coded user account credentials. Lately I’ve implemented Auth0 for login/authentication.
This is the code for Auth0 part:
Auth0
.webAuth()
.scope("openid profile email offline_access account repository:admin")
.audience("https://" + clientInfo.domain + "/userinfo")
.start {
switch $0 {
case .success(let credentials):
guard let accessToken = credentials.accessToken,
let refreshToken = credentials.refreshToken else { return }
SensitiveInfoManager.shared.keychain.setString(accessToken, forKey: .accessToken)
SensitiveInfoManager.shared.keychain.setString(refreshToken, forKey: .refreshToken)
DispatchQueue.main.async {
let main = UIStoryboard(name: "Main", bundle: nil)
let tabbar = main.instantiateInitialViewController()
self.present(tabbar!, animated: true, completion: nil)
}
case .failure(let error):
NSLog("Error authenticating user: \(error)")
SensitiveInfoManager.shared.keychain.clearAll()
}
}
After saving access token I’m using to GET user information. But access token expires immediately. I’m getting 401 “Access token expired. Use your refresh token to obtain a new access token.”
This is Bitbucket’s documentation for OAuth https://developer.atlassian.com/bitbucket/api/2/reference/meta/authentication