import requests
import json
URL = 'https://zoom.us/oauth/token?grant_type=authorization_code&code=XXXXXXXXXXXX&redirect_uri=https://XXXXXX.com'
clientParams= "Basic Q2xpZW50X0lEOkNsaWVudF9TZWNyZXQ=CLIENT_ID:CLIENT_SECRET"
r = requests.post(URL, headers = {'Authorization':clientParams})
data = r.json()
Итак, хотя r.status_code
вернет 200, r.json()
выдаст ошибки.
Вывод:
Traceback (most recent call last):
File "ZoomScript.py", line 10, in <module>
r.json()
File "C:\Users\jasonb\AppData\Local\Programs\Python\Python38-32\lib\site-packages\requests\models.py", line 898, in json
return complexjson.loads(self.text, **kwargs)
File "C:\Users\jasonb\AppData\Local\Programs\Python\Python38-32\lib\json\__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "C:\Users\jasonb\AppData\Local\Programs\Python\Python38-32\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Users\jasonb\AppData\Local\Programs\Python\Python38-32\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
вот первые несколько строк вывода r.content
b'<!doctype html>\n<html xmlns:fb="http://ogp.me/ns/fb#" lang="en-US" >\n<head prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb# zoomvideocall: http://ogp.me/ns/fb/zoomvideocall#">\n<title>Error - Zoom</title>\n<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">\n<meta http-equiv="Content-Type" content="text/html; charset=utf-8"
Это ожидаемый json ответ
{
"access_token": "eyJhbGciOiJI",
"token_type": "bearer",
"refresh_token": "eyJhbGciOiJIUzUxM",
"expires_in": 3599,
"scope": "user:read:admin"
}
Соответствующая ссылка для потока oauth, над которым я пытаюсь работать (это шаг 2): https://marketplace.zoom.us/docs/guides/auth/oauth