Reddit.NET icon indicating copy to clipboard operation
Reddit.NET copied to clipboard

Is authentication a must, even if you only want to read public posts?

Open HubKing opened this issue 3 years ago • 1 comments

The constructor of RedditClient has every parameter defaulting to null, so I thought all were optional, including authentication. But the following code threw an exception "403 forbidden". To use this library, must I authenticate?

        var r = new RedditClient();
        var sr = r.Subreddit("cats");
        var top = sr.Posts.Top[0];

HubKing avatar Dec 28 '22 11:12 HubKing

This is a known issue and it relates to how the Reddit API handles oAuth. Basically, if you're using oAuth (which Reddit.NET does for security reasons), then only a very limited number of public endpoints will actually work. You can find a more detailed explanation of the problem here:

https://stackoverflow.com/questions/42009024/reddit-api-returns-http-403

The solution would be to refactor Reddit.NET to withhold the Authorization header when no tokens are provided. It's on my TODO list. For now, though, app-only authentication support with Reddit.NET is currently limited.

sirkris avatar May 28 '23 03:05 sirkris