# Attempting to obtain bearer token

**URL:** <https://devforum.zoom.us/t/attempting-to-obtain-bearer-token/135072>\
**Category:** Authentication\
**Created:** [July 10, 2025, 3:27pm UTC](https://devforum.zoom.us/t/attempting-to-obtain-bearer-token/135072 "2025-07-10T15:27:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![MP123](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@MP123](https://devforum.zoom.us/u/MP123)\
**Post date:** [July 10, 2025, 3:27pm UTC](https://devforum.zoom.us/t/attempting-to-obtain-bearer-token/135072/1 "2025-07-10T15:27:22Z")

</div>

I’m having trouble attaining a bearer token for a server to server app. Following instructions provided by Zoom for the Server to Server OAuth entry.

I use the following, inserting my ClientID, ClientSecret and AccountId in the respective places.

in powershell:

$creds = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(‘CLIENT\_ID:CLIENT\_SECRET’))

Invoke-WebRequest -Method POST -Uri [https://zoom.us/oauth/token](https://zoom.us/oauth/token) -ContentType ‘application/x-www-form-urlencoded’ -Body @{ grant\_type=‘account\_credentials’; account\_id=‘ACCOUNT\_ID’ } -Headers @{ Host=‘zoom. us’; Authorization=“Basic $creds” }

When I tried this I receive a generic 400 error that doesn’t get logged to the app

I also took the output of the $creds variable and used it for the command prompt options, as shown below.

in Command Prompt

curl -X POST [https://zoom.us/oauth/token](https://zoom.us/oauth/token) -d ‘grant\_type=account\_credentials’ -d ‘account\_id={accountID}’ -H ‘Host: zoom. us’ -H ‘Authorization: Basic Base64Encoded(clientId:clientSecret)’

in this case I receive a “Bad host name error”.

I’ve gone through the FAQ, as well as verified that my app is server-to-server and it is active. I’m not sure what is missing here and could use some help.

As a note I had to add a space in the zoom .us to avoid the link limitation.

---

<div class="post-metadata">

**Author:** ![ticorrian.heard](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/ticorrian.heard/32/70213_2.png) [@ticorrian.heard](https://devforum.zoom.us/u/ticorrian.heard)\
**Post date:** [July 10, 2025, 4:11pm UTC](https://devforum.zoom.us/t/attempting-to-obtain-bearer-token/135072/2 "2025-07-10T16:11:30Z")

</div>

Hi @MP123 I generated a token on my end successfully using the following powershell and curl commands:

```auto
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/x-www-form-urlencoded")
$headers.Add("Authorization", "Basic $creds")
$body = "grant_type=account_credentials&account_id=..."
$response = Invoke-RestMethod 'https://zoom.us/oauth/token' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

```

`curl --location 'https://zoom.us/oauth/token' --header 'Content-Type: application/x-www-form-urlencoded' --header 'Authorization: Basic ...' --data-urlencode 'grant_type=account_credentials' --data-urlencode 'account_id=...'`

Can you reference these examples and try again?

---

<div class="post-metadata">

**Author:** ![MP123](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@MP123](https://devforum.zoom.us/u/MP123)\
**Post date:** [July 18, 2025, 7:28pm UTC](https://devforum.zoom.us/t/attempting-to-obtain-bearer-token/135072/3 "2025-07-18T19:28:38Z")

</div>

Thank you for the response! Both should have worked. I ended up switching the process to a language I use more often and found the base64 encoding was giving me an unexpected conversion. The problem is solved.
