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
JWT Authorization Flow returns OAU-222 "Account does not exist"
Tags: authentication, oauth2
May 28, 2023 at 5:35pm   •   2 replies  •  0 likes
Donald Moore

This is a code sample (JS) for my call to retrieve and access token:

      let URL;
      let baseUrl = 'https://platform.devtest.ringcentral.com';
      let endpoint = '/restapi/oauth/token';
      URL =
        baseUrl +
        endpoint +
        '?' +
        new URLSearchParams({
          grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
          assertion: JWT,
        });
      console.log('URL', URL);
      let TOKENS = await fetch(URL, {
        method: 'POST',
        headers: {
          Accept: 'application/json',
          'Content-Type': 'application/x-www-form-urlencoded',
          Authorization: `Basic ${btoa(clientId + ':' + clientSecret)}`,
        },
      }).then((res) => res.json());
      console.log('TOKENS', TOKENS);



Here's what it returns:

{ "error": "invalid_grant", "errors": [ { "errorCode": "OAU-222", "message": "Account does not exist" } ], "error_description": "Account does not exist" } 


My Client ID, Secret, and JWT are all correct from the downloaded credentials.json file. What could be the issue?

More info:

I'm building this on a service worker to retrieve a Fax (attachment) from the message store. I need the fax in PDF format (as binary).

I can't install the SDK client on a service worker. It has to be done with pure Node.js (and no npm packages). It's a CF Worker.

2 Answers
answered on Oct 28, 2023 at 12:38pm  

Phong Vu,

We are getting the same error using Postman. When we try your suggestion, we get "Unsupported Grant Type". We get past this error if we include the grant type as a query parameter. Can you please carify?

Thanks,

George


 0
answered on May 29, 2023 at 5:53pm  

This must be the body params of the POST, not the query params

{
    grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
    assertion: JWT,
}

 0



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