[英]Python: POST request status code 200 not allowing json conversion
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()
So while r.status_code
will return 200, r.json()
will throw errors.因此,虽然r.status_code
将返回 200, r.json()
将抛出错误。
Output: Output:
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)
here's the first few lines of r.content output这是 r.content output 的前几行
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"
This is the expected json response这是预期的 json 响应
{
"access_token": "eyJhbGciOiJI",
"token_type": "bearer",
"refresh_token": "eyJhbGciOiJIUzUxM",
"expires_in": 3599,
"scope": "user:read:admin"
}
Relevant link for the oauth flow I am trying to work to (This is step 2): https://marketplace.zoom.us/docs/guides/auth/oauth我正在尝试处理的 oauth 流程的相关链接(这是第 2 步): https://marketplace.zoom.us/docs/guides/auth/oauth
To me this seems like there is a redirect happening.对我来说,这似乎发生了重定向。 Maybe just delete &redirect_uri=https://XXXXXX.com
from URL也许只需从 URL 中删除&redirect_uri=https://XXXXXX.com
//XXXXXX.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.