403 error with oauth app only request



I’m trying to make an application that doesn’t require a sign-in process - it will only be accessing publicly available data (mainly the timeline).

I’m trying to get my bearer token, but every time I try to get the input stream of my connection, I get an IOException. I checked the stack trace and it said I have a 403 error for the URL : https://api.twitter.com/oauth2/token

Is this the right resource URL to use when getting my bearer token? I did some research and saw that I might be getting this error because of too many requests, but I’ve been getting this from the first request - or at least the first few (but not enough for me to hit the limit I think).

Any ideas how to even begin debugging this? Thanks!


POST oauth2/token is the correct API method to get an application access token.

How are you generating that request and what parameters are you including?


I’m following this tutorial:

In the method readResponse I give a buffered reader the input stream made by the call connection.getInputStream().

This is where my code throws and IOException and reports the 403 error.