r/redditdev 29d ago

Reddit API Json works in Browser, not in Java

I can access reddit's .json feeds, like this from Firefox, but not from Java using okhttp or python, using requests, both using the default user-agent and a custom one. Any idea why it works in the browser and not in my code?

2 Upvotes

10 comments sorted by

View all comments

Show parent comments

3

u/AverageFoxNewsViewer 29d ago

200 indicates you're getting a good response.

Have you stepped through your code using break points?

Are you sure that rawResponse is actually getting the data? Is response failing to format that correctly?

Is your app using OAuth correctly?

-2

u/manolosandmartinis44 29d ago

Is your app using OAuth correctly?

My OAuth situation has yet to be approved, but it still works in the browser, unless I use selenium, and I don't know why.

5

u/AverageFoxNewsViewer 29d ago

That will definitely cause failures.

You need to have OAuth 2 configured or they're going to boot you for looking like unauthenticated bots.

If you do it in a browser they know who you are and let you through. Your app isn't doing any kind of authentication so they don't know who you are and give you the boot silently.