通过 API 投票时,Reddit 给出 403

Reddit gives 403 when upvoting via API

我已按照 Reddit API 的要求注册为 Web app,以便使用 identity, edit, flair, history, modconfig, modflair, modlog, modposts, modwiki, mysubreddits, privatemessages, read, report, save, submit, subscribe, vote, wikiedit, wikiread 范围进行 Oauth 访问。

我已授权我的应用程序,并已将生成的代码交换为 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 时,出现错误。

{"message": "Forbidden", "error": 403}

我要投票的 link 是 Tim Cook warns of ‘data-industrial complex’ in call for comprehensive US privacy laws

我尝试根据 , and tried using different User-Agent as suggested in 中的答案切换 bearerBearer。似乎没有任何效果。

我错过了什么?

已解决。我需要使用 https://oauth.reddit.com 而不是 www.reddit.com.

You may now make API requests to reddit's servers on behalf of that user, by including the following header in your HTTP requests:

Authorization: bearer TOKEN

API requests with a bearer token should be made to https://oauth.reddit.com, NOT www.reddit.com.