【发布时间】:2022-01-20 08:12:37
【问题描述】:
我已经针对 Reddit 帐户完成了我的第三方应用程序的 oauth 流程,并且我已经获得了该帐户的访问令牌。
现在我的下一个问题是
如何使用访问令牌获取帐户的子版块
我似乎无法确定终点。
有人知道那个端点吗?
谢谢
【问题讨论】:
标签: node.js reddit reddit-access-token
我已经针对 Reddit 帐户完成了我的第三方应用程序的 oauth 流程,并且我已经获得了该帐户的访问令牌。
现在我的下一个问题是
如何使用访问令牌获取帐户的子版块
我似乎无法确定终点。
有人知道那个端点吗?
谢谢
【问题讨论】:
标签: node.js reddit reddit-access-token
Reddit OAuth 文档说,对于 /subreddits/mine/(where) 端点,subreddits OAuth 范围是必要的。
一旦为用户获取了该范围,您就可以使用以下 sn-ps 代码访问该用户的订阅子版块列表:
| View a users subreddits | View in Fusebit |
|---|
// Demonstrate using snooclient and Fusebit
const subscriptions = await redditClient.getSubscriptions().fetchAll();
// OR fetch the first page using a raw HTTP request
// - the User-Agent is necessary, don't forget it!
const access_token = redditClient.fusebit.credentials.access_token;
const httpSubs = await superagent.get(
'https://oauth.reddit.com/subreddits/mine/subscriber')
.set('Authorization', `Bearer ${access_token}`)
.set('User-Agent', 'Fusebit Integration');
const length = httpSubs.body.data.children.length;
ctx.body = {
usingSnoo: `User has ${subscriptions.length} subreddits`,
usingHttp: `The first page has ${length} subreddits`,
};
});
【讨论】: