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.