Web app
按业主要求
Reddit API
对于Oauth访问
identity, edit, flair, history, modconfig, modflair, modlog, modposts, modwiki, mysubreddits, privatemessages, read, report, save, submit, subscribe, vote, wikiedit, wikiread
范围。
我已经授权了我的应用程序,并将生成的代码交换给了
access_token
具有
3600
秒有效期。
'use strict';
let request = require('request');
const USER_AGENT = 'web:com.example.server:v0.0.1 (by /u/sridharrajs)';
const token = '<my access_token within 3600 seconds validity>';
request({
method: 'POST',
url: 'https://www.reddit.com/api/vote',
headers: {
'User-Agent': USER_AGENT,
'Authorization': `bearer ${token}`,
'Content-Type': 'application/x-www-form-urlencoded'
},
form: {
id: "t1_9qy47p",
dir: "1"
},
json: false
}, function (error, response, body) {
if (error) {
console.log('error', error);
} else if (body.error) {
console.log('body.error', body);
}
return console.log(body);
});
但当我试着
upvote a reddit submission using API
,我得到一个错误。
我想说的是
Tim Cook warns of âdata-industrial complexâ in call for comprehensive US privacy laws
bearer
和
Bearer
根据中的答案
Reddit API returns HTTP 403
,并尝试使用不同的
User-Agent
403 error when trying to get data from Reddit API
. 似乎什么都没用。
我错过了什么?