Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter API application-only authentication (with TweetSharp)

I am trying to retrieve public tweets from a server-side application, using application-only authentication (no user context).

The following code works fine:

var service = new TwitterService("<consumer key>", "<consumer secret>");
service.AuthenticateWith("<access token>", "<access token secret>"); 

var options = new ListTweetsOnUserTimelineOptions { ScreenName = "billgates" };

foreach (var tweet in service.ListTweetsOnUserTimeline(options))
    Console.WriteLine(tweet.Text);

However I gather from this diagram that it shouldn't be necessary to provide the access token/secret:

Application-only authentication

However when I remove the call to AuthenticateWith, ListTweetsOnUserTimeline returns null.

It is a limitation of the library, if not, how can I do it?

EDIT

Aas far as I can tell, this calls the GET statuses/user_timeline method that should support application-only authentication, as per the documentation:

API methods that support this form of authentication will contain two rate limits in their documentation, one that is per user (for application-user authentication) and the other is per app (for this form of application-only authentication)

The GET statuses/user_timeline method has these 2 limits shown in its documentation.

like image 978
Xavier Poinas Avatar asked Mar 13 '13 03:03

Xavier Poinas


People also ask

Can I use Twitter API without authentication?

This means that the only requests you can make to a Twitter API must not require an authenticated user. With application-only authentication, you can perform actions such as: Pull user timelines.

How do I authenticate Twitter API?

For authentication purposes, each user has an Access Token (API key) and Access Token Secret (API secret) associated with it. Twitter app - A Twitter app can be created via the Twitter app dashboard page with an approved developer account.

What authentication does Twitter use?

Many of Twitter's enterprise APIs require the use of HTTP Basic Authentication.

Does Twitter use oauth2?

You can select your App's authentication settings to be OAuth 1.0a or OAuth 2.0. You can also enable an App to access both OAuth 1.0a and OAuth 2.0. OAuth 2.0 can be used with the Twitter API v2 only. If you have selected OAuth 2.0 you will be able to see a Client ID in your App's Keys and Tokens section.


1 Answers

I think this in not a limitation of the library, but limitation of the Twitter API.

As far as I know, the ListTweetsOnUserTimeline() method uses statuses/user_timeline API call.

GET statuses/user_timeline

As you can see, this call requires authentication.

You can try to use the Streaming API for getting statuses. I can't help you here since I have only experience with user streams, not public.

Public streams

Besides, the TweetSharp has some problems with streams, I had to switch to Linq2Twitter library.

like image 62
Ronnix Avatar answered Oct 12 '22 17:10

Ronnix