Question

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.


2 replies

Userlevel 1

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

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

Reply