aeromir
(Tom)
1
My server 2 server access token expired recently.
I’m trying to write some PHP code to get a new access token. On this page:
https://marketplace.zoom.us/docs/guides/build/server-to-server-oauth-app/
You say to use this curl command:
curl -X POST -H 'Authorization: Basic Base64Encoder(clientId:clientSecret)' https://zoom.us/oauth/token?grant_type=account_credentials&account_id={accountId}
I’ve tried this but it’s returning a 405 Method Not Allowed error.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://zoom.us/oauth/token?grant_type=account_credentials&account_id=xxxxxxxxxxxxxxxxx”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// Set the Authorization header
$auth = “Basic Base64Encoder(” . base64_encode(“yyyyyyyyyyyyyyyyyyy:zzzzzzzzzzzzzzzzzzzzzzzzzz”). “)”;
curl_setopt($ch, CURLOPT_HTTPHEADER, array(“Authorization: $auth”));
$output = curl_exec($ch);
curl_close($ch);
echo $output;
What’s the correct way to use php to call your api to get a new server 2 server access token?
aeromir
(Tom)
2
I added this to the curl commands:
curl_setopt($ch, CURLOPT_POST, 1);
Now I get this error:
{“status”:false,“errorCode”:-1,“errorMessage”:“Illegal base64 character 28”,“result”:null}
aeromir
(Tom)
3
OK… got it working. Hopefully this helps someone:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “https://zoom.us/oauth/token?grant_type=account_credentials&account_id=XXXXXXXXXXXXXX”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
// Set the Authorization header
$auth = "Basic " . base64_encode(“yyyyyyyyyyyyyyyyyy:zzzzzzzzzzzzzzzzzzzzzz”);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(“Authorization: $auth”));
$output = curl_exec($ch);
curl_close($ch);
echo $output;
Hey @aeromir
Happy to hear that you got it to work and thanks for sharing your solution with the community!
This is extremely valuable!
Cheers!
Elisa
system
(system)
Closed
5
This topic was automatically closed 368 days after the last reply. New replies are no longer allowed.