Requesting access token from PowerShell

Description
I’m looking for a way to use PowerShell, along with my OAuth credentials, to request a token instead of having to request one from the marketplace. I’m following the instructions on https://marketplace.zoom.us/docs/guides/auth/oauth and am currently on step 1. I’m using the code below, which generates an URI that I can access from my web browser and get a response code. If I try either the Invoke-WebRequest or Invoke-RestMethod commands, I get an HTML document instead of a response code.

$clientId = "xxxxx"
$clientSecret = "xxxxx"
$uri = "https://zoom.us/oauth/authorize?response_type=code&client_id=" + $clientId + "&redirect_uri=https://zoom.us"
Invoke-RestMethod -URI $uri -Method Get

Am I going about this the right way? I’d like to be able to request an access token from PowerShell as needed to run automation tasks rather than having to log into the marketplace to request one.

Error
N/A

Which App Type (OAuth / Chatbot / JWT / Webhook)?
OAuth

Which Endpoint/s?
Knowing the API endpoint/s can help us to identify your issue faster. Please link the ones you need help/have a question with.

How To Reproduce (If applicable)
Steps to reproduce the behavior:
→ See my code above.

Hi @jramos ,

Thanks for reaching out about this. Have you tried generating a code sample for your request in Powershell using a tool like Postman?

Here is an example of a code snippet to request an access token in Powershell (RestMethod):

$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Authorization", "Basic {Base64encoded Client ID: Client Secret}")

$response = Invoke-RestMethod 'https://zoom.us/oauth/token?grant_type=authorization_code&code={code}&redirect_uri={redirectUri}' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json

Let me know if this helps,
Will

Thanks for looking into this Will. Thankfully, I found someone on GitHub this morning that has already figured this out. I was able to use the code on that link to generate a token and am now able to make API calls with it.

Awesome, glad to hear it, @jramos !

Best,
Will

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