# Server to Server OAuth: getting "Invalid access token", wants write scopes when it should only need read

**URL:** <https://devforum.zoom.us/t/server-to-server-oauth-getting-invalid-access-token-wants-write-scopes-when-it-should-only-need-read/79454>\
**Category:** API and Webhooks\
**Created:** [November 29, 2022, 4:14pm UTC](https://devforum.zoom.us/t/server-to-server-oauth-getting-invalid-access-token-wants-write-scopes-when-it-should-only-need-read/79454 "2022-11-29T16:14:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve.radabaugh](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/steve.radabaugh/32/43374_2.png) [@steve.radabaugh](https://devforum.zoom.us/u/steve.radabaugh)\
**Post date:** [November 29, 2022, 4:14pm UTC](https://devforum.zoom.us/t/server-to-server-oauth-getting-invalid-access-token-wants-write-scopes-when-it-should-only-need-read/79454/1 "2022-11-29T16:14:01Z")

</div>

I’m trying to pull a list of webinars, but when I do, I’m getting

> Invalid access token, does not contain scopes: [webinar:write:admin, webinar:write]."

This is true, as I have **webinar:read:admin**. The documentation says that I only need **read** to read the list of webinars. Also, I don’t have webinar:write as an option in my scopes.

Code:

```auto
$accountid = "REDACTED";
$clientid = "REDACTED";
$secret = "REDACTED";

$url = "https://zoom.us/oauth/token?grant_type=account_credentials&account_id=" . $accountid;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$headers[] = "Authorization: Basic " . base64_encode($clientid . ":" . $secret);
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$data = curl_exec($ch);
$auth = json_decode($data, true); // token will be with in this json

var_dump( $auth );
$access_token = $auth['access_token'];

var_dump($access_token);

$webinar_get_url = "https://api.zoom.us/v2/users/user@domain.con/webinars";

curl_setopt($ch, CURLOPT_URL, $webinar_get_url);

$webinarheaders[] = "Authorization: Bearer " . $access_token;
curl_setopt($ch, CURLOPT_HTTPHEADER, $webinarheaders);

$data = curl_exec($ch);
$webinars = json_decode($data, true);

var_dump( $data ) ;

```

The result of the first vardump is

```auto
array (size=4)
  'access_token' => string 'REDACTED'... (length=632)
  'token_type' => string 'bearer' (length=6)
  'expires_in' => int 3599
  'scope' => string 'user:read:admin webinar:read:admin webinar_token:read:admin:live_streaming webinar_token:read:admin:local_archiving webinar_token:read:admin:local_recording' (length=156)

```

The result of the last vardump is

```auto
'{"code":4700,"message":"Invalid access token, does not contain scopes: [webinar:write:admin, webinar:write]."}'

```

---

<div class="post-metadata">

**Author:** ![MultiplayerSession](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/multiplayersession/32/66446_2.png) [@MultiplayerSession](https://devforum.zoom.us/u/MultiplayerSession)\
**Post date:** [November 29, 2022, 5:01pm UTC](https://devforum.zoom.us/t/server-to-server-oauth-getting-invalid-access-token-wants-write-scopes-when-it-should-only-need-read/79454/2 "2022-11-29T17:01:34Z")

</div>

Make sure you’re issuing a `GET` request, not a `POST` request. From a quick glance, this line looks suspicious:

> [@steve.radabaugh](#):
>
> `curl_setopt($ch, CURLOPT_POST, TRUE);`

---

<div class="post-metadata">

**Author:** ![steve.radabaugh](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/steve.radabaugh/32/43374_2.png) [@steve.radabaugh](https://devforum.zoom.us/u/steve.radabaugh)\
**Post date:** [November 29, 2022, 5:27pm UTC](https://devforum.zoom.us/t/server-to-server-oauth-getting-invalid-access-token-wants-write-scopes-when-it-should-only-need-read/79454/3 "2022-11-29T17:27:56Z")

</div>

> [@MultiplayerSession](#):
>
> Make sure you’re issuing a `GET` request, not a `POST` request. From a quick glance, this line looks suspicious:
> 
> > [@steve.radabaugh](#):
> >
> > `curl_setopt($ch, CURLOPT_POST, TRUE);`

This was it!  
I just set it back to FALSE on the second request and everything worked.

---

<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:** [December 3, 2023, 9:04am UTC](https://devforum.zoom.us/t/server-to-server-oauth-getting-invalid-access-token-wants-write-scopes-when-it-should-only-need-read/79454/4 "2023-12-03T09:04:50Z")

</div>

Closed on December 3, 2023, 9:04am UTC

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