Search code examples
androidretrofitokhttpreddit

403 on Android for Reddit API but not on browser


When making a request with Retrofit using an OKHttp Client with interceptors to add headers:

(Authorization: Bearer + access_token) (User-Agent: "user_agetn_as_described_by_reddit")

Using the oauth.reddit.com/.json URL as recommended by Reddit, I get a 403. Now, when I do this same thing on Postman or something similar, I get a 200 and the expected JSON.

Is anyone aware of something related to Android or Retrofit or OKHttp that could be causing me this pain?


Solution

  • I was using the auth code instead of the access_token to make my requests. A mistake from my side. You should use the auth code to make a token request.