question

michael-smith15894 avatar image
michael-smith15894 asked Anirban Sen Chowdhary answered

Unauthorized for this grant type - OAU-250

Hello Team,

We want to implement calling functionality in our Application for that we have decided to use RingCentral for that first we need to check it in the demo application. We are using PHP Package.

Here are the details of our Demo Application.

Application Name: SAMI-Aid
Client ID: gyNTMqeBQwGUrp3FUvUnWQ
Client Secret:
vU35UBKyTKuXU5U7UTmLKQv14g2Xe6SQu2hN8RmdrNsQ
Phone number: 16087298509
Username: michaelsmith@samiaid.com
Application Type: Private
Platform Type: Server/Web
Permissions Needed : CallControl , RingOut, SMS, VoIP calling, ReadCallLog, SubscriptionWebhook

Now when I am trying to generate an access token using curl request I got an error like below

curl Request : 

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"

Error : 

HTTP/1.1 400 Bad Request
Server: nginx
Date: Mon, 29 Apr 2019 06:22:19 GMT
Content-Type: application/json;charset=utf-8
Content-Length: 177
Connection: keep-alive
X-Application-Context: application:8080
Content-Language: en
WWW-Authenticate: Bearer realm="RingCentral REST API", error="invalid_request", error_description="Unsupported grant type"
RCRequestId: 241682f6-6a47-11e9-b465-005056bba23b
Pragma: no-cache
Cache-Control: no-store
AceRoutingKey: sjc11-c01-ace11.9388ce32-6221-11e9-9962-005056bb6e9b
X-HLB-Server: sjc11-c01-hlb11
X-HLB-Connection: 258276277
X-HLB-RequestId: 36bedbf45d90735908111a4727ed16f1
X-HLB-Upstream-Server: 10.28.21.144:8080
X-HLB-Upstream-Status: 400

{
  "error" : "invalid_request",
  "error_description" : "Unsupported grant type",
  "errors" : [ {
    "errorCode" : "OAU-250",
    "message" : "Unsupported grant type"
  } ]
}


When I am trying to generate a token using " https://developers.ringcentral.com" panel, It's working fine. Please find Attachment
topic-default
1 |1000

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

anton-nikitin avatar image
anton-nikitin answered
For security reasons you have to use 3-legged OAuth flow with authorization_code grant type in web applications. See  https://developers.ringcentral.com/guide/basics/oauth#authorization-code-flow
1 |1000

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
If you move on with the current app, see this quick start for a demo  https://developers.ringcentral.com/guide/authentication/quick-start/authorization-flow/php

Otherwise, if you want to use the password flow authentication, create a new app and select the Server-only (No UI) for the Platform Type. See this demo  https://developers.ringcentral.com/guide/voice/quick-start/php
1 |1000

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

If you're using an OAuth 2.0 request using the OAuth 2.0 password grant (grant_type=password), then your application you created should in the RingCentral Developer Portal should be Password flow .

Please note, application created with different platform type will have different grant_type.

For example, application created for platform type = browser based will have grant_type=Authorization Code | Implicit | Refresh Access Token where as application for platform type = Desktop/Windows will have grant_type= Authorization Code | Password flow |Refresh Access Token

So in order to use (grant_type=password) you need to have application created with platform type that support Password flow

Here is wonderful way it has answered with animated Gif image that will easily help you to understand the proccess: https://stackoverflow.com/questions/47692828/ringcentral-auth-token-failed-in-curl-call-unauthorized-for-this-grant-type/47745436#47745436

1 |1000

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

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.