curl command for requesting access token

  • 1
  • Question
  • Updated 6 months ago
What is the curl command for requesting an access token using Password Flow?
Photo of Nick Lagerquist

Nick Lagerquist

  • 140 Points 100 badge 2x thumb

Posted 1 year ago

  • 1
Photo of Automation USA

Automation USA

  • 1,040 Points 1k badge 2x thumb
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
Photo of Tyler Long

Tyler Long, Official Rep

  • 5,190 Points 5k badge 2x thumb
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"
(Edited)
Photo of Automation USA

Automation USA

  • 1,040 Points 1k badge 2x thumb
Awesome! So then the -u option implies "Basic" auth.
Photo of Nick Lagerquist

Nick Lagerquist

  • 110 Points 100 badge 2x thumb
Thanks for the responses. That solved that problems I was having.
Photo of Robert Raj

Robert Raj

  • 152 Points 100 badge 2x thumb
Hi all,Still i got Unauthorized for this grant type
Photo of Tyler Long

Tyler Long, Official Rep

  • 5,190 Points 5k badge 2x thumb
Please create a new app and make sure that it supports the password authorization flow.