question

nick-lagerquist5249 avatar image
nick-lagerquist5249 asked Leonard leWang Deactivated action

curl command for requesting access token

What is the curl command for requesting an access token using Password Flow?

authentication
1 |3000

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

Julio Toledo avatar image
Julio Toledo answered Tyler Liu commented
curl -X POST "https://platform.ringcentral.com/restapi/oauth/token" 
-H "Accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded" -H "Authorization: Basic <access-token>" -d "username=<user-phone-number>&password=<user-password>&extension=<user-extension>&grant_type=password
Source:
https://developer.ringcentral.com/api-docs/latest/index.html#!#RefPasswordFlow
6 comments
1 |3000

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

Tyler Liu avatar image Tyler Liu ♦ commented ·
You don't need to manually do base64 encoding:
curl -X POST "https://platform.devtest.ringcentral.com/restapi/oauth/token"; \
-H "Accept: application/json" \
-H "Content-Type: application/x-www-form-urlencoded" \
-u "<appKey>:<appSecret>" \
-d "username=<username>&password=<password>&extension=<extension>&grant_type=password"
1 Like 1 ·
Julio Toledo avatar image Julio Toledo commented ·
Oops, by "<access-token>" I meant to say Base64 Encoded appKey + appSecret
0 Likes 0 ·
Julio Toledo avatar image Julio Toledo commented ·
Awesome! So then the -u option implies "Basic" auth.
0 Likes 0 ·
nick-lagerquist5249 avatar image nick-lagerquist5249 commented ·
Thanks for the responses. That solved that problems I was having.
0 Likes 0 ·
robert-raj8062 avatar image robert-raj8062 commented ·
Hi all,Still i got Unauthorized for this grant type
0 Likes 0 ·
Show more comments
Anirban avatar image
Anirban answered

Here the problem you are facing is the header Authorization which is Basic <base64 of appKey:appSecret> .. If you pass that header in curl, your problem will be solved

1 |3000

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

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys