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

时间:2021-03-26 05:12:14

标签: python api flask python-requests

上下文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)

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

1 个答案:

答案 0 :(得分:1)

令牌请求 (RFC 6749 Section 4.1.3) 的 Content-Type 必须是 application/x-www-form-urlencoded 尽管 令牌响应 (RFC 6749 { {3}}) 是 JSON。