繁体   English   中英

从 reddit api 获取 api 誓言访问令牌

[英]Get the api oath access token from reddit api

我从 reddit oauth api 成功获得了代码,但是之后尝试获取访问令牌时,我得到了无效的授权(在我以 json 格式发送数据时获得 401 未授权之前)错误。 我正在使用邮递员将发布请求发送到https://www.reddit.com/api/v1/access_token这是我在邮递员中使用的标题和表单数据。 我正在从邮递员的授权选项卡中发送我的客户端 ID 和密码(尝试发送标头),并使用 x-www-form-urlencoded 发送授权类型、代码和重定向 uri(尝试将它们作为表单数据和 json 发送) . 在标题中,我的内容类型是 x-www-form-urlencoded。 如果有人使用过 reddit api,请帮助获取令牌。

//Headers
Content-Type:application/x-www-form-urlencoded
//authorization
Authorization:Basic Base.Encode64(clientid:secret)
//client id and secret are those which I got by creating the app in reddit
//x-www-form-urlencoded.
{
    "grant_type":"authorization_code",
    "code":"authcode which I got from the get request before",
    "redirect_uri":"http://localhost:3000"
}
//I tried sending these through query string as well

如果我没记错的话,你的令牌会在 3600 分钟后过期

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM