Skip to main content

Hi, RC team, hope you're doing well!

I've been having an issue getting JWT authorization to work. I'm able to successfully get an access token in Postman, but in my code, I only get error code OAU-250 (unsupported grant type). I've tried to follow the directions of the technical guide and by looking at other posts here.

In Postman, I'm using a POST request with endpoint: https://platform.devtest.ringcentral.com/restapi/oauth/token
Authorization: I entered Basic Auth with my clientId and clientSecret as Username and Password, respectively.


Headers are auto-generated by Postman; I don't add any custom ones. Note that when Postman creates the Authorization header, its value becomes "Basic " and then the base64 encoding of my clientId:clientSecret. I can confirm here too that Content-Type is "application/x-www-form-urlencoded".


Finally for the Body, where I've chosen x-www-form-urlencoded, the grant_type is "urn:ietf:params:oauth:grant-type:jwt-bearer" and the assertion is my JWT.

All of this results in a successful POST request where I get the appropriate access/refresh tokens, scope, and all.


In the code, however, I try to follow the above as close as possible, but I keep on getting that OAU-250 error. Note that I have to use ScriptEase, a dialect of JavaScript.

My API Configuration looks like the following [identifying info omitted]:

var config = {
"url": "https://platform.devtest.ringcentral.com/restapi/oauth/token",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Accept":"application/json",
    "Authorization": "Basic " + uclientId:clientSecret, base64 encoded together],
    //"Content-Type": "application/x-www-form-urlencoded",
    "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
  },
  "body": {
    //"grant_type":"urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer",
    "grant_type":"urn:ietf:params:oauth:grant-type:jwt-bearer",
    "assertion":omy JWT],
  }
};

// I then try to make my request with:

var client = new HttpClient(config.url);
var request = new HttpRequest('POST', '');
request.addHeaders(config.headers);
request.setBody(config.body.toString(), "application/x-www-form-urlencoded");
var response = client.sendRequest(request);


As seen above, I've tried both variants of grant_type (with and without the %3A character for the colons), and nothing I've tried on my end has worked. The response comes back as OAU-250 mstatus code 400]. Would you happen to know what may be the cause of this or what I should try changing? Please let me know if you have any questions.

Wishing you all the best!

Are you sure you are using the same app client id and client secret on your code? Give me the app client id so I can see what type of authentication you have set for your app.


Hi, Phong, thank you for replying! The client ID for my app is: Y01bLHERQaKzJiBgc8tPYQ and I have it set to JWT Auth Flow.


Thanks for sharing the app client id. Checked and the app auth type is correct. So I think the issue is in your code.

Is there any reason you don't use one of our SDKs?



Hi, Phong, thank you for the suggestion. I did take some time trying to use the JavaScript version of the RC SDK using some of that boilerplate code from index.js. I felt that ScriptEase (the language I am using) would be able to take plain JavaScript; I may be missing something though, as even the basic code to create it [ var RC = require ('@ringcentral/sdk').SDK ] registers as a syntax error/script fails to be interpreted. I've tried switching things around and such (like hardcoding the env variables), but have you or someone on your team ever encountered someone working in a ScriptEase environment?


Reply