# How to get an access token using Python 3.7

**URL:** <https://devforum.zoom.us/t/how-to-get-an-access-token-using-python-3-7/29011>\
**Category:** API and Webhooks\
**Created:** [September 3, 2020, 8:52am UTC](https://devforum.zoom.us/t/how-to-get-an-access-token-using-python-3-7/29011 "2020-09-03T08:52:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kurono](https://avatars.discourse-cdn.com/v4/letter/k/258eb7/32.png) [@kurono](https://devforum.zoom.us/u/kurono)\
**Post date:** [September 3, 2020, 8:52am UTC](https://devforum.zoom.us/t/how-to-get-an-access-token-using-python-3-7/29011/1 "2020-09-03T08:52:31Z")

</div>

**Description**  
The text may be weird because I am using Google Translate, but thank you.

I want to get an access token from OAuth this time using AWS Lambda and Python 3.7.

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

**How To Reproduce (If applicable)**  
I cannot use JWT because I am using my company Zoom account. So I want to implement it with OAuth.  
The PHP code and test request below worked fine, but I don’t know how to get it in Python.

```
<?php
session_start();
$Client_ID = '"xxxxxxxxx"';
$Client_Secret = 'xxxxxx';
$Redirect_URL ='xxxxxx';
if(isset($_GET['code'])){
	$basic = base64_encode($Client_ID.':'.$Client_Secret);
	$curl = curl_init();
	curl_setopt_array($curl, array(
		CURLOPT_URL => "https://zoom.us/oauth/token?grant_type=authorization_code&code={$_GET['code']}&redirect_uri=$Redirect_URL",
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_ENCODING => "",
		CURLOPT_MAXREDIRS => 10,
		CURLOPT_TIMEOUT => 30,
		CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
		CURLOPT_CUSTOMREQUEST => "POST",
		CURLOPT_HTTPHEADER => array(
			"authorization: Basic $basic"
		),
	));
	$response = curl_exec($curl);
	$err = curl_error($curl);
	curl_close($curl);
	if ($err) {
		echo "cURL Error #:" . $err;
	} else {
		echo $response;
	}
}else{
	echo 'Authorization Error';
}
?>
```

---

<div class="post-metadata">

**Author:** ![DeveloperBot](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/developerbot/32/12632_2.png) [@DeveloperBot](https://devforum.zoom.us/u/DeveloperBot)\
**Post date:** [September 3, 2020, 8:53am UTC](https://devforum.zoom.us/t/how-to-get-an-access-token-using-python-3-7/29011/2 "2020-09-03T08:53:16Z")

</div>

Hey @kurono

Thanks for posting on the Zoom Devforum! I am still learning, but I will try my best to help answer your question. 🙂

Checkout this related thread that may have the answer you are looking for:

> [@Requesting Access Token via Python](https://devforum.zoom.us/t/-/6637):
>
> Description/Error I want to know how can i request access token for an OAuth App using Python. Do you have a template? I already have client-id and client-secret. I want to get access token now via Python script which I want to run locally on my machine. I can successfully generate the token by using "Send a Test Request " feature but now I am looking how to do it using python code.

If this thread did not help, please let us know by replying back here and someone from the Developer Relations team will get back to you shortly.

Thanks,  
DeveloperBot

---

<div class="post-metadata">

**Author:** ![kurono](https://avatars.discourse-cdn.com/v4/letter/k/258eb7/32.png) [@kurono](https://devforum.zoom.us/u/kurono)\
**Post date:** [September 3, 2020, 9:11am UTC](https://devforum.zoom.us/t/how-to-get-an-access-token-using-python-3-7/29011/3 "2020-09-03T09:11:58Z")

</div>

Thanks for suggesting the solution!  
But it didn’t work.

---

<div class="post-metadata">

**Author:** ![kurono](https://avatars.discourse-cdn.com/v4/letter/k/258eb7/32.png) [@kurono](https://devforum.zoom.us/u/kurono)\
**Post date:** [September 4, 2020, 9:24am UTC](https://devforum.zoom.us/t/how-to-get-an-access-token-using-python-3-7/29011/4 "2020-09-04T09:24:59Z")

</div>

First of all, how do I get the authorization code using Python?

---

<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:** [September 8, 2020, 9:21pm UTC](https://devforum.zoom.us/t/how-to-get-an-access-token-using-python-3-7/29011/5 "2020-09-08T21:21:19Z")

</div>

Hey @kurono,

Have you had a chance to check out our OAuth Guide’s “Getting an Access Token” section yet?

> **[OAuth 2.0 - Authorization - Documentation](https://marketplace.zoom.us/docs/guides/auth/oauth#getting-access-token)**
>
> OAuth with Zoom
> 
> The Zoom API uses OAuth 2.0 to authenticate and authorize users to make requests. To setup access credentials and request scopes for yo...

Step 1 in this guide only needs to be done once. After you install/authorize the OAuth app, you’ll use the auth code in the url to request an access token (in any language—our APIs are platform/language agnostic).

It’s not until Step 2 in this guide where your Python code would start. It would use the access\_token (which lasts one hour) returned in step 1. Once it expires, you need to use the latest refresh\_token to get a new access\_token. So keep in mind that you’ll need to store this access\_token/refresh\_token each time a new one is requested/refreshed.

After these steps, you can use your up to date access\_token to hit any API endpoint of interest. When it comes to hitting a particular API endpoint, you can retrieve the code snippet in your language of choice from the embedded Postman tool in our API documentation. But to be clear, we do not have an end-to-end sample app, in Python, for our entire OAuth flow at this time.

I hope this helps to clarify!

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:** [October 9, 2020, 7:21am UTC](https://devforum.zoom.us/t/how-to-get-an-access-token-using-python-3-7/29011/6 "2020-10-09T07:21:20Z")

</div>

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