Created
February 15, 2023 22:19
-
-
Save joelsteidl/fad398aab245b828a13a218e9640ad0a to your computer and use it in GitHub Desktop.
Proof of concept for connecting to Zoom's Server to Server Oauth App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// See https://marketplace.zoom.us/docs/guides/build/server-to-server-oauth-app/ | |
// See 1PW for Credentials. | |
$client = \Drupal::httpClient(); | |
$options = [ | |
'auth' => ['YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET'], | |
'form_params' => [ | |
'account_id' => 'YOUR_ACCOUNT_ID', | |
'grant_type' => 'account_credentials', | |
], | |
]; | |
// Gets the bearer token. | |
$response = $client->post('https://zoom.us/oauth/token', $options); | |
$response_data = json_decode($response->getBody()->getContents(), TRUE); | |
// Note: Access Token has an expiration. Could be worth saving? | |
// Could also automatically retry on failure? | |
if (!isset($response_data['access_token'])) { | |
// log something~! | |
} | |
// Add authorization header. | |
$options = [ | |
'headers' => [ | |
'Authorization' => 'Bearer ' . $response_data['access_token'], | |
], | |
]; | |
$response = $client->get('https://api.zoom.us/v2/users', $options); | |
$response_data = json_decode($response->getBody()->getContents(), TRUE); | |
print_r($response_data); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment