question

pratap-s5689 avatar image
pratap-s5689 asked Anirban answered

CURL command to get access token not working

Hi


I am trying to get my access token using curl command. I looked at Question "https://devcommunity.ringcentral.com/ringcentraldev/topics/curl-command-for-requesting-access-token" but it is not working for me.


I am always getting : { "error" : "invalid_grant",

"error_description" : "Invalid resource owner credentials."

}


My credential are correct and also I tried with secret/access key and enoced it to base64 as well but for both the cases its throwing me the same above error.


If my credential are invalid I should not be able to login to web dashboard itself. I am bit confused here and not sure where I am going/doing wrong.


Thanks,

Pratap

errors
1 |1500 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.

Tyler Liu avatar image
Tyler Liu answered
curl -i -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=&grant_type=password"


If it doesn't work. It's probably because your credential is wrong.

Please note that, you cannot use a sandbox credential for production or vice versa.
1 |1500 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.

pratap-s5689 avatar image
pratap-s5689 answered
Thanks it turn out to be I was using production for devtest :( . Also I want to disable expires for access_token and refresh_token. How can we achieve this? Also I was looking for CURL API commands to post messages to Glip goup chat is that possible?
1 |1500 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.

Tyler Liu avatar image
Tyler Liu answered
It's impossible to disable token expires. You can set them to the maximum expires_in value. As far as I can tell, access token  expires in one hour. Refresh token lifetime is typically limited to one week

It is possible to use CURL to post messages to Glip group. Please have a try and create a new ticket if you have difficulties.
1 |1500 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 avatar image
Anirban answered

"Also I want to disable expires for access_token and refresh_token. How can we achieve this? "

In any OAuth system in the earth, there is no way to disable expires for access_token and refresh_token because that will be a security issue. You cannot use a permanent access_token and refresh_token as that contradict the idea of OAuth Security system.

1 |1500 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.

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