# Requesting access token from PowerShell

**URL:** <https://devforum.zoom.us/t/requesting-access-token-from-powershell/41638>\
**Category:** API and Webhooks\
**Created:** [January 26, 2021, 8:09pm UTC](https://devforum.zoom.us/t/requesting-access-token-from-powershell/41638 "2021-01-26T20:09:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jramos](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jramos/32/40761_2.png) [@jramos](https://devforum.zoom.us/u/jramos)\
**Post date:** [January 26, 2021, 8:09pm UTC](https://devforum.zoom.us/t/requesting-access-token-from-powershell/41638/1 "2021-01-26T20:09:56Z")

</div>

**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](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.

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [January 27, 2021, 5:01pm UTC](https://devforum.zoom.us/t/requesting-access-token-from-powershell/41638/2 "2021-01-27T17:01:54Z")

</div>

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):

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

---

<div class="post-metadata">

**Author:** ![jramos](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/jramos/32/40761_2.png) [@jramos](https://devforum.zoom.us/u/jramos)\
**Post date:** [January 27, 2021, 7:40pm UTC](https://devforum.zoom.us/t/requesting-access-token-from-powershell/41638/3 "2021-01-27T19:40:20Z")

</div>

Thanks for looking into this Will. Thankfully, I found someone on [GitHub](https://gist.github.com/hthoma/8715fc28523270141aa11cb8c87d4138) 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.

---

<div class="post-metadata">

**Author:** ![will.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/will.zoom/32/14417_2.png) [@will.zoom](https://devforum.zoom.us/u/will.zoom)\
**Post date:** [January 27, 2021, 8:34pm UTC](https://devforum.zoom.us/t/requesting-access-token-from-powershell/41638/4 "2021-01-27T20:34:40Z")

</div>

Awesome, glad to hear it, @jramos !

Best,  
Will

---

<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:** [February 27, 2021, 6:35am UTC](https://devforum.zoom.us/t/requesting-access-token-from-powershell/41638/5 "2021-02-27T06:35:01Z")

</div>

Closed on February 27, 2021, 6:35am UTC

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