简体   繁体   English

Python:POST 请求状态码 200 不允许 json 转换

[英]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.

相关问题 Python json POST请求状态为200,而预期状态为201 - Python json POST request status 200 while expecting status 201 Python请求循环,如果状态码不是200,则重试 - Python request loop, retry if status code not 200 Python POST 请求返回 404 状态代码,但 GET 请求返回 200 - Python POST Request returns 404 status code but GET request returns 200 Web 用 python 抓取,request.json() 显示 status_code 为 200 但无法提取 json 数据 - Web scraping with python, request.json() shows status_code of 200 but can not extract json data 为什么在我的帖子请求中得到返回码 200 而不是 201? (Python/请求/Json) - Why did I get return code 200 instead of 201 on my post request ? (Python /Requests/Json) python request.get 总是抛出状态码 200 - python request.get always throws status code 200 python 请求获取状态码 200 但 response.content 为空 - python request get status code 200 but response.content is empty Python POST 请求返回代码 200 但不存储文件 - Python POST request return code 200 but not storing the file Python 发布请求响应状态为“200”,但在所需页面中没有发布任何内容 - Python post request response status is "200" but when nothing is getting posted in the desired page Python requests.post() 方法命令返回 200 status_code 属性而不是 500 - Python requests.post() method command returns 200 status_code attribute instead of 500
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM