OAU-213 TokenInvalid, while calling refresh token
Jan 26, 2023 at 5:02pm • 1 replies • 0 likes
Avijit Chauhan
We are using the OAuth Authorization Code flow, although while calling the refresh token, even when the refresh token is valid.
The access token is valid and works with other APIs when it is valid, although when we call API for a refresh token, it is giving us an invalid token.
I checked the forum for the solutions, although neither the token seems to be corrupted, nor the password has changed. Can you please assist us with the same?
I am attaching the code for the same below:
Authorization Code to get access token:
self.url = f"{self.API_Server_URL}/restapi/oauth/tok clientId_clientSecret =f"{self.rc_clientId}:{self.rc_clientSecret}" clientId_clientSecret_bytes = clientId_clientSecret.encode("ascii") base64_bytes = base64.b64encode(clientId_clientSecret_bytes) base64_clientId_clientSecret = base64_bytes.decode("ascii") headers = { "Authorization": f"Basic {base64_clientId_clientSecret}" } params = { "grant_type": "authorization_code", "code": code, "redirect_uri": self.redirect_uri + "/ringcentral/auth", "client_id": self.rc_clientId, "client_secret": self.rc_clientSecret, "refresh_token_ttl":604800 } responseData = requests.post(self.url, headers=headers, data=params)
Code used for getting refresh token:
clientId_clientSecret = f"{rc_clientId}:{rc_clientSecret}" clientId_clientSecret_bytes = clientId_clientSecret.encode("ascii") base64_bytes = base64.b64encode(clientId_clientSecret_bytes) base64_clientId_clientSecret = base64_bytes.decode("ascii") brand_type = obj.get('brand_type') url = f"{API_Server_URL}/restapi/oauth/token" if brand_type: url = url.replace(".com", ".biz") headers = { "Content-Type": "application/x-www-form-urlencoded", "Accept": "application/json", "Authorization": f"Basic {base64_clientId_clientSecret}" } params = { "refresh_token": obj.get("refresh_token"), "grant_type": "refresh_token", "endpoint_id": obj.get("endpoint_id") } responseData = requests.post(url, headers=headers, data=params)
1 Answer
Fix these first and run again to see if it helps
// Login body params params = { "grant_type": "authorization_code", "code": code, "redirect_uri": self.redirect_uri + "/ringcentral/auth" // "refresh_token_ttl":604800 // Unneccessary } // Refresh body params = { "refresh_token": obj.get("refresh_token"), "grant_type": "refresh_token" }
0
A new Community is coming to RingCentral!
Posts are currently read-only as we transition into our new platform.We thank you for your patience
during this downtime.
Try Workflow Builder
Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!Try RingCentral Workflow Builder