Using Server-To-Server OAuth

I’ve been using JWT to get webinar schedules, but now that JWT is deprecated, I’m trying to use Server-To-Server OAuth instead.

Is there an example implementation in PHP?

@akira.k , you can use back the same code to get details from the web service. To generate an access token in PHP, you will do something like this.

<?php

$config = include 'config.php';


// Access the environment variables
$clientId  = $config['client_id'];
$clientSecret  = $config['client_secret'];
$accountId= $config['account_id'];
$oauthUrl = 'https://zoom.us/oauth/token?grant_type=account_credentials&account_id=' . $accountId;  // Replace with your OAuth endpoint URL

function getAccessToken() {
    global $clientSecret, $clientId, $oauthUrl;


    try {
        // Create the Basic Authentication header
        $authHeader = 'Basic ' . base64_encode($clientId . ':' . $clientSecret);
        echo "authHeader: " . $authHeader .  PHP_EOL;
        // Initialize cURL session
        $ch = curl_init($oauthUrl);

        // Set cURL options
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: ' . $authHeader));

        // Execute cURL session and get the response
        $response = curl_exec($ch);

        // Check if the request was successful (status code 200)
        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        if ($httpCode == 200) {
            // Parse the JSON response to get the access token
            $oauthResponse = json_decode($response, true);
            $accessToken = $oauthResponse['access_token'];
            return $accessToken;
        } else {
            echo 'OAuth Request Failed with Status Code: ' . $httpCode . PHP_EOL;
            echo $response . PHP_EOL;
            return null;
        }

        // Close cURL session
        curl_close($ch);
    } catch (Exception $e) {
        echo 'An error occurred: ' . $e->getMessage() . PHP_EOL;
        return null;
    }
}

?>
1 Like

I have developed (or should I say ‘configured’) a Zoom Server-to-Server OAuth app to integrate a Joomla extension (Events Booking) and Zoom. The point is to allow a user to sign up for an Events Booking ‘event’ which is a Zoom meeting or webinar and have their information sent to Zoom for registration with the particular Zoom meeting or webinar. It seems to be working as far as I can see. In testing, I receive a confirmation from Zoom with the details of the Zoom Meeting - name, time, date, link, passcode, etc. However, when I check the list of Registrants for the event, I am not seeing any signs of registrations. While I was still debugging the non-Zoom end of this, I was able to see registrants appear in the Zoom Event registrants list but I was also seeing the generic error page at https://us02web.zoom.us/meeting/register/tZUsfuCprTotH9cxE4baBi_5X3RsXQZE0LzS

Now that I have cleaned up some things I no longer see that error page, I DO see the Zoom registration confirmation email, but I DO NOT see the registrant (me) listed in the list of registrants for the Zoom Meeting.

This doesn’t make a lot of sense to me - but I’m not much of an expert with Zoom. How is this happening? I’d expect either the registration confirmation email is sent AND the registrant appears in the list of registrants, or the registration email does NOT get sent, and the registrant does NOT appear in the list of registrants.
if
How/Why would a registration confirmation email be sent but the registrant does not appear in the list of registrants for the Zoom Meeting? Might this have something to do with the person already having been registered (during my testing two days ago)?