Reddit Api 获取访问令牌

Reddit Api Get Access Token

您好,我想为我的 reddit 帐户获取访问令牌吗?我正在尝试使用我的 https://ssl.reddit.com/api/v1/access_token 电子邮件地址和密码登录,但它不起作用。谢谢! 我试试看

import requests
r = requests.get("https://www.reddit.com/api/v1/access_token?grant_type=password&username=Emrovsky&password=mypass!")

我按照 the post I linked 中的步骤进行操作并且成功了。这是 Python 代码:

import requests
from requests.auth import HTTPBasicAuth

data = {
    'grant_type': 'password',
    'username': '{your username}',
    'password': '{your password}'
}

r = requests.post("https://ssl.reddit.com/api/v1/access_token",
                  data=data,
                  auth=HTTPBasicAuth('{your apps client id}', '{your apps secret key}'))

print(r.text)

USERNAME must be registered as a developer of the OAuth 2 client ID you send.

显然,应用程序需要已经创建。