News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Error Code OAU-250 despite using appropriate grant_type (JWT)
Tags: developer sandbox, authentication, problem
May 8, 2023 at 2:42pm   •   2 replies  •  0 likes
Jonathan So

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 " + [clientId: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":[my 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 [status 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!

2 Answers
answered on May 9, 2023 at 7:58am  

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?



 0
on May 9, 2023 at 2:08pm   •  0 likes

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?

answered on May 8, 2023 at 3:00pm  

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.


 1
on May 9, 2023 at 5:38am   •  0 likes

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



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us