question

A Feibus avatar image
A Feibus asked A Feibus commented

Console app trying to JWT authorize in the sandbox and getting Unauthorized for this grant type

I swear I set it up right, but it's failing, and I can't figure out where to look. Using C# and latest SDK.

Using Fiddler, I see that the call to https://platform.devtest.ringcentral.com/restapi/oauth/token, with this info:

grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=eyJraWQiOiI4NzYyZjU5OGQwNTk0NGRiODZiZjVjYTk3ODA0NzYwOCIsInR5cCI6IkpXVCIsImFsZyI6IlJTMjU2In0..... (not putting the whole token here, but it's in the parms).

Says it's using TLS1.2, so that's right. Returns:

{
  "error" : "unauthorized_client",
  "errors" : [ {
    "errorCode" : "OAU-251",
    "message" : "Unauthorized for this grant type"
  } ],
  "error_description" : "Unauthorized for this grant type"
}

App is set up to use JWT (I also tried setting to password auth with the right user/ext/password and that returned the same outcome). The JWT token is correct. What did I do wrong? Once the 400 happens, authorize call hangs.

Thanks in advance.

developer sandboxauthentication
2 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.

Before investigating your case, can you give me the app client id so I can have a look at the app settings.

0 Likes 0 ·
A Feibus avatar image A Feibus Phong Vu ♦♦ ·

1A_7xhOcR1OKhkuFetzZfQ


thank you!

0 Likes 0 ·

1 Answer

Phong Vu avatar image
Phong Vu answered A Feibus commented

Can you try it now. I changed the app scope from public to private as the JWT was personal and the platform type is server-only. Let me know if your app must be a public app.

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

Halfway there maybe.

Getting a 200 response with a token, so that part looks right (see below). But, the .Authorize call

rc.Authorize(ConfigurationManager.AppSettings["RC Token"]).Wait();

isn't coming back from the Wait() still. What else is it waiting on?

The plan is that this customer is the only one to ever run it, so private is perfect.

In case you need it, Fiddler shows the response came back with something like this:

{
  "access_token" : "U0pDMTJQMDFQQVMw....",
  "token_type" : "bearer",
  "expires_in" : 3600,
  "refresh_token" : "U0pDMTJQMDFQQVMw....",
  "refresh_token_expires_in" : 604800,
  "scope" : "Faxes",
  "owner_id" : "714822005",
  "endpoint_id" : "y-janHULTiaQuTUOmX6gbg"
}
0 Likes 0 ·

if it's not returned, how do you get the tokens then? Pls share some code (w/o sensitive info)

0 Likes 0 ·
A Feibus avatar image A Feibus Phong Vu ♦♦ ·

Using Fiddler to see the requests and responses.

Code is inside an asynchronous routine, and looks like this, and I'm seeing the packets for the .Authorize() call, but the .Wait just sits and never returns.

var rc = new RestClient(ConfigurationManager.AppSettings["RC Client"], ConfigurationManager.AppSettings["RC Secret"], ConfigurationManager.AppSettings["RC URL"]);
rc.Authorize(ConfigurationManager.AppSettings["RC Token"]).Wait();
0 Likes 0 ·
Show more comments

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