question

Donald Moore avatar image
Donald Moore asked George Schally answered

JWT Authorization Flow returns OAU-222 "Account does not exist"

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.

authenticationoauth2
1 |3000

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

Phong Vu avatar image
Phong Vu answered

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,
}
1 |3000

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

George Schally avatar image
George Schally answered

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

1 |3000

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

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