question

Victor Rungta avatar image
Victor Rungta asked ·

Unable to refresh access token

App Type: Server/Web

curl Request:

curl --location --request POST 'https://platform.devtest.ringcentral.com/restapi/oauth/token' \

--header 'Content-Type: application/x-www-form-urlencoded' \

--header 'Authorization: Basic U0pDMTJQMDFQQVMwMHxBQUNxSkdJOW1pZDltYzhIRjJfMlVqTlY3di14WUZIYkFtR1Q2TlpVbjZzU3ZPc3JPdmRGVFJMNlpvWnZDbUJ6Q09oNF9QWWRPMEVYNENYQjd4dmJsWHJoWnlrSXJvM3ZieXM4RWFEc3FFZ0lVRzREa0NSelVRVTV6dGYyQVdWeWhkSDlvNHhLdlB3eUNNT010LVhJX1RjNE8zMXhJRzM5MnFPbFNYNVdFMnFwalllNFdjN0l2TS1rdTlJOFluRlpUZ09sdE16Q3JSMHJMbVI0TUZHVXNURDN8d2NJTW1BfDJNeTVtalRwZ1VtSEs1MjBIdG15M3d8QUE' \

--data-urlencode 'refresh_token=U0pDMTJQMDFQQVMwMHxBQUNxSkdJOW1pZDltYzhIRjJfMlVqTlY3di14WUZIYkFtR1Q2TlpVbjZzU3ZPc3JPdmRGVFJMNlpvWnZDbUJ6Q09oNF9QWWRPMEVYNENYQjd4dmJsWHJobjZBM3pZTEkyemc4RWFEc3FFZ0lVQ2V4dFY3WWpnMnN6dGYyQVdWeWhkSDlvNHhLdlB3eUNNT010LVhJX1RjNE8zMXhJRzM5MnFPbFNYNVdFMnFwalllNFdjN0l2TS1rdTlJOFluRlpUZ1BfUEhRQ3RxaUNGVVRsQjdtbG9uVXR8d2NJTW1BfHg0X2d1Wk1NcTdEWXFWc2lYbkVKTkF8QUE' \

--data-urlencode 'grant_type=refresh_token'


Response: 400 Bade Request

{

"error": "invalid_request",

"errors": [

{

"errorCode": "OAU-156",

"message": "Basic authentication header is missing or malformed"

}

],

"error_description": "Basic authentication header is missing or malformed"

}


Can you guys help me how to refresh access token.

oauth2refresh access token
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Phong Vu avatar image
Phong Vu answered ·

Your header is incorrect as you used the refresh token.

--header 'Authorization: Basic U0pDMTJQMDFQQVMwMHxBQUNxSkdJOW1pZDltYzhIRjJfMlVqTlY3di14WUZIYkFtR1Q2TlpVbjZzU3ZPc3JPdmRGVFJMNlpvWnZDbUJ6Q09oNF9QWWRPMEVYNENYQjd4dmJsWHJoWnlrSXJvM3ZieXM4RWFEc3FFZ0lVRzREa0NSelVRVTV6dGYyQVdWeWhkSDlvNHhLdlB3eUNNT010LVhJX1RjNE8zMXhJRzM5MnFPbFNYNVdFMnFwalllNFdjN0l2TS1rdTlJOFluRlpUZ09sdE16Q3JSMHJMbVI0TUZHVXNURDN8d2NJTW1BfDJNeTVtalRwZ1VtSEs1MjBIdG15M3d8QUE' \

The Authorization header must be a based64 encoded string of "client id" + ":" + " client secret"

Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Anirban Sen Chowdhary avatar image
Anirban Sen Chowdhary answered ·

url: https://platform.devtest.ringcentral.com/restapi/oauth/token (POST)

Your Header:

Content-Type: application/x-www-form-urlencoded

Authorization: Basic <Base 64 of client id : client secret>

In your post body:

grant_type=refresh_token&refresh_token=<refresh token>

3 comments Share
1 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Incorrect!

To refresh a token you don't need to specify the username and password anymore!

0 Likes 0 · ·

@Phong Vu .. just realized that ... corrected .. thanks

0 Likes 0 · ·
Jared Wood avatar image Jared Wood Anirban Sen Chowdhary ·

This is exactly right. But does anyone know where it states this in the documentation? I've looked over every possible page and cannot come to this same conclusion on my own. Awful documentation.

1 Like 1 · ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.