https://www.reddit.com/r/redditdev/comments/tjl1c8/bug_gated_subreddits_inaccessible_via_oauth/
created by talklittle on 21/03/2022 at 20:21 UTC
7 upvotes, 1 top-level comments (showing 1)
There is a new HTTP 403 Forbidden reason: "gated" with a content warning for certain subreddits. For example /r/MorbidReality.
Normally your browser gets past it by doing a POST to `/gated` and Reddit sets a cookie with value:
_options={%22pref_gated_sr_optin%22:true};
This cookie works on api.reddit.com too. But the cookie is completely ignored on oauth.reddit.com. So there is no way to access these subreddits on OAuth while remaining unsubscribed to them. A poor workaround is to join the subreddit.
Really, the "gated" error should not apply to API clients. Cookies should not be involved.
Comment by Watchful1 at 21/03/2022 at 20:29 UTC
6 upvotes, 1 direct replies
There was a post here two days ago about this[1] that had a solution, but the author deleted it. I'll see if I can reproduce the solution.
1: https://www.reddit.com/r/redditdev/comments/thut8k/some_subreddits_api_are_gated_now/
Edit:
const https = require('https') const options = { hostname: 'api.reddit.com', path: '/r/MorbidReality/about', headers: { 'user-agent': 'test user agent', cookie: 'edgebucket=; _options={%22pref_gated_sr_optin%22:true}', }, }\ const req = https.request(options, res => { res.on('data', d => { process.stdout.write(d) }) }) req.end()
There's the code he had. So looks like you can get it working if you format the cookie the right way.