【问题标题】:the authorization grant type is not supported by the authorization server osu api授权服务器 osu api 不支持授权授予类型
【发布时间】:2021-03-26 05:12:14
【问题描述】:

上下文osu api documentation

用户将按下登录按钮,该按钮会将他们定向到授权网站osu auth

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

  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)

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

【问题讨论】:

  • 你可以试试在 post 方法中用 "json =" 而不是 "body=" 吗?
  • 好吧,我试过了,它给了我 {"error":"client authentication failed"} 所以它做了一些事情,你认为你可以向我解释为什么 json= 比 data=/body 更好=?
  • "json=" 发送一个 json 可序列化的 python 对象,而 "data=" 发送一个包含 json doc 的字符串实例。您应该在发送表单数据内容类型时使用数据,而为其他内容类型发送 json。
  • 哦,好的,我明白了。您还认为您知道为什么会出现该错误或已修复吗?
  • 您发送的正文参数之一似乎是错误的。我建议先浏览 osu 文档并检查何时抛出此错误

标签: python api flask python-requests


【解决方案1】:

Token Request (RFC 6749 Section 4.1.3) 的 Content-Type 必须为 application/x-www-form-urlencoded,尽管 Token Response (RFC 6749 Section 4.1.4) 的格式为JSON。

【讨论】:

  • 当我使用它时,它会返回授权服务器不支持的授权授权类型。
猜你喜欢
  • 2017-03-29
  • 1970-01-01
  • 1970-01-01
  • 2023-04-09
  • 1970-01-01
  • 2022-01-08
  • 2018-05-26
  • 2018-07-01
  • 2017-05-14
相关资源
最近更新 更多