How do I get Bearer token?

Description
I’m trying to call the Zoom API from a Google APPs Script (in javascript).
I’ve set up my app on Zoom Marketplace as a: [Server-to-server OAuth]
and as an [Account-level app]

I’m trying to follow the Zoom API documentation for making a GET User Details call (as per this portion of the Zoom API documentation).

However I keep getting the below error:
{“code”:124,“message”:“Invalid access token.”}

I’m using my app’s Client Secret as the bearer token in the API call.
Sorry - bit new at this so any help would be much appreciated!

My code

function getZoomUser() {
var USER_EMAIL = ‘tommy.t@mydomain.org’
var apiUrl = “https://api.zoom.us/v2/users/”+USER_EMAIL;

var headers = {
“Content-Type”: “application/json”,
“Authorization”: “Bearer myAppClientSecret”
};

var options = {
method: “GET”,
headers: headers,
muteHttpExceptions: true,
};

var response = UrlFetchApp.fetch(apiUrl, options);
Logger.log(response);
}

Hi @phil.l
If you are using a Server to Server Oauth app, you will need to use the account credentials to generate an access token, here is a link to our Docs:

Once you generate the token, you can pass this token as your Bearer token in the API call you are making

Hope this helps,
Elisa

Aha! Perfect! That’s worked.
Thanks so much :slight_smile:

1 Like