Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Unable to refresh token in iOS App

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)

        }

Best Answer
0 Votes
1 REPLY 1

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
0 Votes