API Endpoint(s) and/or Zoom API Event(s)
https://api.zoom[.]us/v2/accounts/{{AccountID}}/report/operationlogs
https://api.zoom[.]us/v2/accounts/{{AccountID}}/report/activities
Description
Due to the retirement of JWT applications in September, we are attempting to migrate our existing JWT integration querying these endpoints to a Server-to-Server OAuth app. We set up the application with the following scopes: report:master and report:read:admin. This is a new application as of July 2023 that has never successfully been able to query these endpoints.
Querying the API https://zoom[.]us/oauth/token
does generate the expected output listed in the documentation: an access token with the appropriate scopes. Querying either endpoint with this access token always fails with the message “Invalid access token”.
Error?
401 Unauthorized error with the following JSON response:
{
"code": 124,
"message": "Invalid access token."
}
How To Reproduce
PowerShell is below. I have also tried similar queries using curl
and Postman and can share those setups but none have gotten past the 124 error. Note that the $AccountID
, $ClientID
, and $ClientSecret
variables are defined above this code and set to the appropriate values.
function ConvertTo-Base64($plain) {
# Converts $plain to a b64 string
return [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes($plain))
}
# Format account credentials for request
$b64ClientID_ClientSecret = ConvertTo-Base64($ClientID + ":" + $ClientSecret)
# Prep for OAuth Token request
$oauthHeaders = @{ Host='zoom.us'; Authorization="Basic $($b64ClientID_ClientSecret)" }
$oauthURL = "https://zoom.us/oauth/token"
$oauthBody = @{ grant_type='account_credentials'; account_id=$AccountID }
# Retrieve Access Token and Token Type from Zoom
# This returns a JSON object containing access_token, token_type, expires, and scope fields
$oauth = Invoke-WebRequest -Method POST -Uri $oauthURL -ContentType 'application/x-www-form-urlencoded' -Body $oauthBody -Headers $oauthHeaders
# Parse $oauth as a PowerShell object
$oauthDetails = $oauth | ConvertFrom-Json
# Prep Headers for API call
$headers = @{'Authorization'="$($oauthDetails.token_type) $($oauthDetails.access_token)"}
$url = "https://api.zoom.us/v2/accounts/$($AccountID)/report/activities"
# Query /report/activities API
# This always returns the { "code": 124, "message": "Invalid access token." } response
$response = Invoke-WebRequest -Method Get -UseBasicParsing -Headers $headers -Uri $url