Zoom API access_token fetch from Zoom API documentation code are different than from Zoom marketplace.zoom.us Get Access Token Button

Description
Zoom API access_token fetch from Zoom API documentation code are different than from Zoom marketplace Get Access Token Button

Error
When Using the access_token from this code I can’t create a meeting.

Which App Type (OAuth / Chatbot / JWT / Webhook)?
OAuth

Which Endpoint/s?
access_token

Additional context
My code chunk to get access token is:

var request = require(“request”);

var options = {
method: ‘POST’,
url: ‘https://zoom.us/oauth/token?grant_type=client_credentials’,
headers: {
/**The credential below is a sample base64 encoded credential. Replace it with “Authorization: 'Basic ’ + Buffer.from(your_app_client_id + ‘:’ + your_app_client_secret).toString(‘base64’)”
**/
Authorization: 'Basic ’
}
};

request(options, function (error, response, body) {
if (error) throw new Error(error);

var obj = JSON.parse(body);
var token = obj.access_token;
console.log(JSON.parse(body));
});

It gives the output:

{
access_token: ‘token’,
token_type: ‘bearer’,
expires_in: 3600,
scope: ‘account:master account:read:admin account:write:admin meeting:master meeting:read:admin meeting:write:admin recording:master recording:read:admin recording:write:admin user:master user:read:admin user:write:admin webinar:master webinar:read:admin webinar:write:admin’
}

And for creating a meeting I simply copy the access token and pass into the next code. The code is below:

var request = require(“request”);
var options = {
method: “POST”,
url: “https://api.zoom.us/v2/users/me/meetings”,
headers: {
“content-type”: “application/json”,
authorization:
"Bearer ", //it changes every 30 mins
},
body: {
agenda: “”,
assistant_id: “”,
created_at: “2020-11-06T05:42:54.522Z”,
timezone: “Asia/Kolkata”,
encrypted_password: “”,
h323_password: “”,
host_email: “rex@workwithme.in”,
host_id: “blEqWHKgT2OoQkGQPGBs1Q”, //input your host id
id: “”,
join_url: “”,
password: “7msSQ”,
pstn_password: “”,
settings: {
alternative_hosts: “”,
approval_type: 2,
audio: “both”,
auto_recording: “none”,
close_registration: false,
cn_meeting: false,
enforce_login: false,
enforce_login_domains: “”,
host_video: true,
in_meeting: false,
join_before_host: false,
meeting_authentication: false,
mute_upon_entry: false,
participant_video: true,
registrants_confirmation_email: true,
registrants_email_notification: true,
request_permission_to_unmute_participants: false,
use_pmi: false,
waiting_room: true,
watermark: false,
},
start_url: “”,
status: “started”,
timezone: “Asia/Kolkata”,
topic: “Pintu Das’ Zoom Meeting”,
type: 1,
uuid: “”,
},
json: true,
};

request(options, function (error, resp, body) {
if (error) throw new Error(error);

console.log(body);
console.log(resp.body.join_url);
});

It gives me an error:

{ code: 200, message: ‘Invalid api key or secret.’ }
undefined

Hi @rex-workwithme,

Thanks for reaching out, and happy to help take a closer look. Please note that I redacted some of the tokens you provided, as these contain sensitive information.

To clarify, are you saying that the API response when calling https://zoom.us/oauth/token returns an invalid access_token? If this is the case, can you share the full URL (including the code value you’re passing) with us at developersupport@zoom.us? Happy to take a closer look. (Please don’t share these details here.)

Note that in your URL to hit the oauth endpoint, the grant_type value should be the value of the code you receive from the URL after a user authorizes your app. At the moment, it seems like you may be passing a different value.

Thanks,
Will

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.