# Code 124 - Invalid Access Token with New Server-to-Server OAuth app

**URL:** <https://devforum.zoom.us/t/code-124-invalid-access-token-with-new-server-to-server-oauth-app/92943>\
**Category:** API and Webhooks\
**Tags:** api, s2s-oauth\
**Created:** [August 4, 2023, 3:08pm UTC](https://devforum.zoom.us/t/code-124-invalid-access-token-with-new-server-to-server-oauth-app/92943 "2023-08-04T15:08:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![algo](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@algo](https://devforum.zoom.us/u/algo)\
**Post date:** [August 4, 2023, 3:08pm UTC](https://devforum.zoom.us/t/code-124-invalid-access-token-with-new-server-to-server-oauth-app/92943/1 "2023-08-04T15:08:20Z")

</div>

**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](https://developers.zoom.us/docs/internal-apps/s2s-oauth/#use-account-credentials-to-get-an-access-token): 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:

```auto
{
    "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.

```auto
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

```

---

<div class="post-metadata">

**Author:** ![algo](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@algo](https://devforum.zoom.us/u/algo)\
**Post date:** [August 11, 2023, 2:20pm UTC](https://devforum.zoom.us/t/code-124-invalid-access-token-with-new-server-to-server-oauth-app/92943/2 "2023-08-11T14:20:54Z")

</div>

Does anyone have any ideas as to what could be causing this? I am still experiencing this issue.

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [August 21, 2023, 7:36pm UTC](https://devforum.zoom.us/t/code-124-invalid-access-token-with-new-server-to-server-oauth-app/92943/3 "2023-08-21T19:36:03Z")

</div>

Hi @algo  
Thanks for reaching out to us and sorry for the late reply here!  
Can you please confirm that you have a master account license enabled in your account?  
If so, when you generate your token, do you get the scopes listed in the list of scopes ?

---

<div class="post-metadata">

**Author:** ![algo](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@algo](https://devforum.zoom.us/u/algo)\
**Post date:** [August 21, 2023, 8:04pm UTC](https://devforum.zoom.us/t/code-124-invalid-access-token-with-new-server-to-server-oauth-app/92943/4 "2023-08-21T20:04:25Z")

</div>

Hi @elisa.zoom!

Thank you for getting back to me on this. I can confirm both of those - please see the image below. I’ve redacted the access token itself, but this is the output I receive when completing the request in Postman.

 ![ZoomToken](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/c/d/cd47d56d814418bb374ea41a54cda2eaa61ba485.png)

Attempting to use the token from that output always results in the same error:

```auto
{
    "code": 124,
    "message": "Invalid access token."
}

```

---

<div class="post-metadata">

**Author:** ![elisa.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/elisa.zoom/32/47836_2.png) [@elisa.zoom](https://devforum.zoom.us/u/elisa.zoom)\
**Post date:** [August 22, 2023, 4:42pm UTC](https://devforum.zoom.us/t/code-124-invalid-access-token-with-new-server-to-server-oauth-app/92943/5 "2023-08-22T16:42:10Z")

</div>

Thanks for your quick reply here @algo  
I will send you a private message to follow up with more details

---

<div class="post-metadata">

**Author:** ![algo](https://avatars.discourse-cdn.com/v4/letter/a/e99b99/32.png) [@algo](https://devforum.zoom.us/u/algo)\
**Post date:** [August 24, 2023, 2:12pm UTC](https://devforum.zoom.us/t/code-124-invalid-access-token-with-new-server-to-server-oauth-app/92943/6 "2023-08-24T14:12:17Z")

</div>

For anyone else with the same problem: I was confusing two of Zoom’s APIs. In the [Meeting API documentation](https://developers.zoom.us/docs/api/), it lists a [REST API section](https://developers.zoom.us/docs/api/rest/reference/zoom-api/methods/#overview) and a [Master access API](https://developers.zoom.us/docs/api/rest/reference/zoom-api/methods/#overview) section. My app was configured to allow the REST API access _ **but not the Master API access** _, but I was attempting to query the Master API endpoints.

Switching my app access to match the REST API requirements and querying the correct endpoints resolved this issue for me.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [August 25, 2023, 2:13pm UTC](https://devforum.zoom.us/t/code-124-invalid-access-token-with-new-server-to-server-oauth-app/92943/7 "2023-08-25T14:13:11Z")

</div>

Closed on August 25, 2023, 2:13pm UTC

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