vyshakhbabji avatar image
vyshakhbabji Deactivated posted Leonard leWang Deactivated edited

Why does OAuth return "unauthorized for this grant type" error?

Are you receiving the following error when you call the /oauth/token API to authorize your application?

"error": "unauthorized_client"
"error_description": "Unauthorized for this grant type"

To fix this problem, check the following:

Is your "application type" ==> "Web/UI based" or "browser-based application?"

If the answer is yes you will need to follow the 3 legged OAuth flow to authorize your application.

The authorization code flow provides the following benefits:

  • a consistent and trusted UI
  • integrated password reset
  • integrated single sign-on (SSO) via SAML support

For more information please check out the following:

1 |3000

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

duane-smith1885 avatar image duane-smith1885 commented ·
I'm also getting this exact same error using Advanced REST client and desktop application.
0 Likes 0 ·
ak avatar image ak commented ·
Hi Duane,

Could you please check the application type, login to the developer portal ( ) and click on the application and under settings you should see the "Platform Type" . If the platform type is any one of below :
  • Browser-Based
  • Server-Web
  • Server-Only
Then you would need to follow the OAuth 2.0 Code flow for authentication. You could find more information and sample codes here :
0 Likes 0 ·
chris-dierdorff5904 avatar image chris-dierdorff5904 ak commented ·
the information here is telling us what OAuth 2.0 is, not how to use it. Are there any resources that help new developers actually USE this auth type? 
1 Like 1 ·
duane-smith1885 avatar image duane-smith1885 commented ·

It's a desktop application. In Platform Type I have Desktop/Windows.

I'm using  Resource Owner Password Credentials Flow (ROPC), also named  Password Flow.

Using the SDK c# code tests from RingCentral, it works fine. However, running very similar .net 2.0 code it doesn't. Also, running the RingCentral API Explorer and Advanced REST client doesn't work. Here's the code I'm using:

        Dim client As New WebClient()        
        Dim parameters As String = "grant_type=password" &
                                   "&username=15623520324" &
                                   "&extension=101" &
                                   "&password=" & password
        Dim URL As String = GetUrl("restapi/oauth/token")
        client.Headers.Add(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded;charset=UTF-8")
        client.Headers.Add(HttpRequestHeader.Authorization, "Basic " & GetApiKey())
        Dim result As String = client.UploadString(URL, "POST", System.Web.HttpUtility.UrlEncode(parameters))
        Return result

0 Likes 0 ·
zeeshan-yousaf2030 avatar image zeeshan-yousaf2030 commented ·
Hi, i m trying to use JS Liberary  but getting same error. if some one could guide it would be great help my code as below:

$(document).ready(function() {
 //var RC_SERVER_SAOX = '';
 var rcsdk = new RingCentral.SDK({
 var platform = rcsdk.platform();
        username: '+4420377136XX', // phone number in full format which is given under sandbox credentials

        extension: '301', // Admin default

        password: 'XXXXXXXXXXXXX' // Here my ringcentral developer account password

    .then(function(response) {
          // your code here
    .catch(function(e) {
        alert(e.message  + 'Server cannot authorize user');
0 Likes 0 ·
cfhe-reception1779 avatar image cfhe-reception1779 commented ·
The following works fine for me. Maybe it will help.

Public Const RingCentralTokenURI = " "
Public Const LoginUserName = "%2B18185555555"
Public Const LoginPassword = "mypassword"

Dim httpRequest As New MSXML2.XMLHTTP
Dim PayLoad As String

PayLoad = "grant_type=password&username=" & LoginUserName & "&extension=119&" & "password=" & LoginPassword
httpRequest.Open "POST", RingCentralTokenURI, False
httpRequest.setRequestHeader "Authorization", "Basic xxxxxxxxxxxxxxxxxxx"    httpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded;charset=UTF-8"
httpRequest.Send PayLoad
Access_Token = "Bearer " & Mid(Mid(httpRequest.responseText, InStr(1, httpRequest.responseText, """access_token"" : """) + 18), _
        1, InStr(1, Mid(httpRequest.responseText, InStr(1, httpRequest.responseText, """access_token"" : """) + 18), """,") - 1)

 Debug.Print Access_Token

0 Likes 0 ·

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



Rylie-Community_Moderator contributed to this article Leonard3223650020 contributed to this article ByrneReese contributed to this article vyshakhBabji contributed to this article