Discord 的 OAUTH2 客户端证书授予不起作用

问题描述 投票:0回答:0

这是我正在使用的代码

import requests

CLIENT_ID = 'USER_ID'
CLIENT_SECRET = 'PASSWORD'

def get_token():
  data = {
    'grant_type': 'client_credentials',
    'scope': 'identify connections'
  }
  headers = {
    'Content-Type': 'application/x-www-form-urlencoded',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'
  }
  r: requests.Response = requests.post(
                                        'https://discord.com/api/oauth2/token',
                                        data=data,
                                        headers=headers,
                                        auth=(CLIENT_ID, CLIENT_SECRET)
                                      )
  return r.json()

print(get_token())

这是发送的原始请求

POST /api/oauth2/token HTTP/1.1
Host: discord.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36
Accept-Encoding: gzip, deflate
Accept: */*
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 56
Authorization: Basic VVNFUl9JRDpQQVNTV09SRA==

grant_type=client_credentials&scope=identify+connections

这是回应

{'error': 'invalid_client'}

使用代码 401 UnAuthorized


使用的凭据是 100% 正确的,因为我已经尝试了多次。

那我做错了什么?

任何帮助将不胜感激谢谢!

python oauth-2.0 python-requests discord
© www.soinside.com 2019 - 2024. All rights reserved.