Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 授权服务器osu api不支持授权授予类型_Python_Api_Flask_Python Requests - Fatal编程技术网

Python 授权服务器osu api不支持授权授予类型

Python 授权服务器osu api不支持授权授予类型,python,api,flask,python-requests,Python,Api,Flask,Python Requests,上下文 用户将按下登录按钮,该按钮将引导他们进入授权网站 然后将被重定向回带有代码的网站 code = request.query_string name_verify = str(code).split('code=')[1] #re.search("(?!\w+=)\w+", str(code)) #getting the code print(name_verify) response = requests.post("https://

上下文

用户将按下登录按钮,该按钮将引导他们进入授权网站

然后将被重定向回带有代码的网站

  code = request.query_string

  name_verify = str(code).split('code=')[1]
  #re.search("(?!\w+=)\w+", str(code)) #getting the code
  print(name_verify)

  response = requests.post("https://osu.ppy.sh/oauth/token", data = { 'client_id': xxxx, 'client_secret': "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", 'redirect_uri': "https://osu-api-crap.minecreeper0913.repl.co", 'scope':'public', 'code': name_verify, 'grant_type':'authorization_code'}, headers={'Accept': 'application/json', 'Content-Type': 'application/json'})

  print(response.text)

我被告知这是正确的方法,但它总是导致“授权服务器不支持授权授予类型”

令牌请求(RFC 6749)的内容类型必须是
application/x-www-form-urlencoded
,尽管令牌响应的格式是(RFC 6749)是JSON。

你能在post方法中尝试使用“JSON=”而不是“body=”吗?好吧,我试过了,它给了我{“error”:“client authentication failed”}所以它做了一些事情,你认为你能向我解释为什么JSON=优于data=/body=?“JSON=”发送一个JSON可序列化的python对象,而“data=”发送包含json文档的字符串实例。您应该在发送表单数据内容类型时使用数据,而json用于其他内容类型。另外,您认为您知道为什么会出现该错误或进行修复吗?看起来您发送的某个主体参数是错误的。我建议先查看osu文档,并检查何时会出现此错误。当我使用时,它会返回到授权服务器不支持的授权授予类型。