Search code examples
androidiostwittertwitter-oauth

Get Twitter Home timeline without authentication(App only authentication)


I was trying to get user home timeline with this request

 `https://api.twitter.com/1.1/statuses/home_timeline.json?screen_name=zaheer6110&count=20`

but getting this error all the time "Your credentials do not allow access to this resource" I have successfully got user timeline by https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=zaheer6110&count=20 now don't know how to resolve this because in documentation there is no example to get Home timeline with screen name.


Solution

  • App only authentication allow you to access resources from your application context. Not from a specific user account context (not even the account owning the app).

    As you can see statuses/user_timeline.json?screen_name=zaheer6110 specifies the screen_name of the user you want to access to.

    But the statuses/home_timeline.json endpoint is account specific. What it means is that it returns the tweet of the authenticated account. But as you are using Application only credentials, Twitter does not have any account to run the request against.

    If you want to get a home timeline, you will have to authenticate with some user credentials (Access Token and Access Token Secret).

    The account specific endpoints are specified in the documentation under Resource Information > Requires authentication. They are marked as Yes (user context only). You can find the documentation of HomeTimeline here.

    You can generate a set of Access Tokens keys for your account on https://apps.twitter.com/app/