# New App-can't retrieve OAuth2 Access Token --\> invalid authorization code, invalid grant

**URL:** <https://devforum.zoom.us/t/new-app-cant-retrieve-oauth2-access-token-invalid-authorization-code-invalid-grant/63656>\
**Category:** API and Webhooks\
**Created:** [February 2, 2022, 5:59pm UTC](https://devforum.zoom.us/t/new-app-cant-retrieve-oauth2-access-token-invalid-authorization-code-invalid-grant/63656 "2022-02-02T17:59:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![johanne.lemaire](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/johanne.lemaire/32/34726_2.png) [@johanne.lemaire](https://devforum.zoom.us/u/johanne.lemaire)\
**Post date:** [February 2, 2022, 5:59pm UTC](https://devforum.zoom.us/t/new-app-cant-retrieve-oauth2-access-token-invalid-authorization-code-invalid-grant/63656/1 "2022-02-02T17:59:06Z")

</div>

## Using this template helps us debug your issues more effectively 🙂

**Description**  
I am trying to create meetings via Python

- I have created an app, not published on Marketplace
- I have retrieved an authorization code
- I hade made the request to get the access token and refresh token and get an Error

I have already tried:

- create a new authorization code and run the POST request again, same result

**Error**  
b’{“reason”:“Invalid authorization code”,“error”:“invalid\_grant”}’

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

**Which Endpoint/s?**  
not there yet 🙂 , but planning to

1. view user, and
2. create meetings

**How To Reproduce (If applicable)**  
Steps to reproduce the behavior:  
1.  
`https://zoom.us/oauth/authorize?response_type=code&client_id=[Redacted]&redirect_uri=MYURL`  
2. grab the Authentication code from the response to 1  
3. run the POST request

```auto
def get_access_token(app_credentials):
	"""
	Get the access token from Zoom

	arguments:
	app_credentials -- dic of Zoom app credentials
	              {'name': MY_APP_NAME,
                   'clientID': CLIENT_ID,
                   'client_secret': CLIENT_SECRET,
                   'verification_token': VERIFICATION_TOKEN,
				   'redirect_url': REDIRECT_URL,
				   'code from redirect': CODE_FROM_REDIRECT,
				   'authorization_code': AUTHORIZATION_CODE
                   }

	returns:
	None
	"""
	url = f"https://zoom.us/oauth/token?grant_type=authorization_code&code={app_credentials.get('code from redirect')}&redirect_uri={app_credentials.get('redirect_url')}"

	payload = {}

	header_autho = "Basic {}".format(base64.b64encode(bytes("{}:{}".format(app_credentials.get('clientID'), app_credentials.get('client_secret')).encode("utf - 8"))).decode("utf - 8"))
	headers = {
	  'Authorization': header_autho
	}

	response = requests.request("POST", url, headers=headers, data = payload)
	print(response.text.encode('utf8'))

	return None

```

**Additional context**  
I am a user on an enterprise account, and only want to use the app for my own user ID

Forum post I found helpful in getting me this far:  
[Understanding OAuth for Zoom - API and Webhooks - Zoom Developer Forum](https://devforum.zoom.us/t/understanding-oauth-for-zoom/12444/2)

---

<div class="post-metadata">

**Author:** ![donte.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/donte.zoom/32/24412_2.png) [@donte.zoom](https://devforum.zoom.us/u/donte.zoom)\
**Post date:** [April 22, 2022, 1:18pm UTC](https://devforum.zoom.us/t/new-app-cant-retrieve-oauth2-access-token-invalid-authorization-code-invalid-grant/63656/2 "2022-04-22T13:18:22Z")

</div>

Hi, @johanne.lemaire,

Thank you for posting – happy to help! Here is a Python script you can use to Get an Access Token:

```auto
import http.client

conn = http.client.HTTPSConnection("zoom.us")
payload = ''
headers = {
  'Authorization': 'Basic YOUR-KEY/SECERT',
  'Cookie': '_zm_lang=en-US; _zm_mtk_guid=b2fed383f6f345c78ef07479027467b9; _zm_visitor_guid=b2fed383f6f345c78ef07479027467b9'
}
conn.request("POST", "/oauth/token?grant_type=authorization_code&code=YOURCODE&redirect_uri=YOURREDIRECT", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

```

Let me know if this helps.

Best,  
Donte
