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

Using this template helps us debug your issues more effectively :slight_smile:

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 :slight_smile: , 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

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

Hi, @johanne.lemaire,

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

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