I am not abe to refresh the token in my iOS app, any pointer/tutorial help will be very much appreciated.
Here is the code snippet :
let refreshURL = URL(string: "https://api.fitbit.com/oauth2/token")
let request = NSMutableURLRequest(url: refreshURL!)
request.httpMethod = HTTPMethod.post.rawValue
request.cachePolicy = NSURLRequest.CachePolicy.reloadIgnoringCacheData
let savedRefreshToken = UserDefaults.standard.string(forKey: UserDefaultKeys.FitBitoAuthRefreshToken)
let grantType = ""
let parameters = [
"grant_type": "refresh_token",
"refresh_token": savedRefreshToken
]
let headers = [
"Authorization":"Basic XXXXXXXXXX",
"Content-Type":"application/x-www-form-urlencoded"
]
Alamofire.request(refreshURL!, method: .post, parameters: parameters as Parameters, headers: headers).responseString() { response in
debugPrint(response)
print(response)
}
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Hi @Developer12,
Welcome to the forums!
Could you please tell me what error code and message you are seeing when you try to refresh a token? Also, could you PM me your Client ID so I can check our logs?
Thanks!
Best Answer