# Can't fetch bearer token

**URL:** <https://devforum.zoom.us/t/cant-fetch-bearer-token/114854>\
**Category:** Authentication\
**Created:** [August 2, 2024, 3:57am UTC](https://devforum.zoom.us/t/cant-fetch-bearer-token/114854 "2024-08-02T03:57:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![maisum](https://avatars.discourse-cdn.com/v4/letter/m/ba8739/32.png) [@maisum](https://devforum.zoom.us/u/maisum)\
**Post date:** [August 2, 2024, 3:57am UTC](https://devforum.zoom.us/t/cant-fetch-bearer-token/114854/1 "2024-08-02T03:57:49Z")

</div>

Hi, I am trying to send a request to Zoom API. I can retrieve my bearer token but when I use it to Zoom API, I am getting an error: {“code”:124,“message”:“This API does not support client credentials for authorization.”}. I tried to change the grant\_type to account\_credentials but I am getting this error when fetching the token {“reason”:“unsupported grant type”,“error”:“unsupported\_grant\_type”}.

This is my code:  
def fetch\_bearer\_token():  
client\_id = os.getenv(“ZOOM\_CLIENT\_ID”)  
client\_secret = os.getenv(“ZOOM\_CLIENT\_SECRET”)

```
if not client_id or not client_secret:
    raise ValueError("Client ID and Client Secret must be set in environment variables.")

credentials = base64.b64encode(f"{client_id}:{client_secret}".encode()).decode()
token_url = "https://zoom.us/oauth/token"
headers = {
    'Authorization': f'Basic {credentials}',
    'Content-Type': 'application/x-www-form-urlencoded',
}
payload = {
    'grant_type': 'account_credentials'
}

response = requests.post(token_url, headers=headers, data=payload)
if response.status_code == 200:
    return response.json()['access_token']
else:
    raise Exception(f"Error fetching bearer token: {response.text}")

```

How can I fix this? Is it possible to get the token without a redirect\_url?

---

<div class="post-metadata">

**Author:** ![chunsiong.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/chunsiong.zoom/32/35488_2.png) [@chunsiong.zoom](https://devforum.zoom.us/u/chunsiong.zoom)\
**Post date:** [August 2, 2024, 8:49am UTC](https://devforum.zoom.us/t/cant-fetch-bearer-token/114854/2 "2024-08-02T08:49:02Z")

</div>

@maisum are you doing this over python?
