Yortw / tweetmoasharp

TweetSharp is a fast, clean wrapper around the Twitter API.
Other
72 stars 22 forks source link

Any plans for application-only authorization? #62

Closed viswalshms closed 7 years ago

viswalshms commented 7 years ago

The ability to pull down a public timeline would be a welcome addition... and would solve a big problem for me particularly. I really only need it for GET statuses/user_timeline...

Yortw commented 7 years ago

I'm afraid I don't have any specific plans for this. TBH, I actually thought it worked already - I presume you've tried it and it doesn't?

I'd be happy to accept a good PR with tests, otherwise I can leave this issue open and if I or someone else gets time to look at it, it might happen.

viswalshms commented 7 years ago

I haven't tried it, but the reason is that I didn't see the BearerToken exposed when I browsed the library. I have 4.0.0, but I didn't see anything to indicate that you'd added anything of the sort in 4.0.1. Since I need to be able to do this without a user authenticated, application-only authorization seems to be a show-stopper if it's not there.

If I can find the time, I'll pull the code and see if I can figure out a way to get it done.

Yortw commented 7 years ago

I haven't tried it myself, but I believe if you provide a consumer token and secret to the constructor of TwitterService, then make calls using the via that instance, they are made as the application (auth) with no user context. There is no need to expose the bearer token since the TwitterService makes the requests and authorises them internally (this is probably what I would have done, but it's actually someone else's design I'm just maintaining).

Calls that require a user context will fail as the Twitter API will reject the call, but calls that support app auth should succeed.

viswalshms commented 7 years ago

I'll give it a try and let you know.

viswalshms commented 7 years ago

Got an exception:

Value cannot be null. Parameter name: source

Code looks like this:

        TwitterService Twitterer = new TwitterService(TwitConsumerKey, TwitConsumerSecret); 
        ListTweetsOnUserTimelineOptions lto = new ListTweetsOnUserTimelineOptions();
        lto.ScreenName = "user";
        lto.Count = 5;
        lto.IncludeRts = false;
        lto.ExcludeReplies = true;
        lto.TrimUser = true;
        lto.SinceId = options.lasttweetID;
        List<TwitterStatus> tweets = Twitterer.ListTweetsOnUserTimeline(lto).OrderByDescending(data => data.Id).ToList();
Yortw commented 7 years ago

This should hopefully work now in 4.0.2 which I just published to Nuget. Should be available in 15 mins or so.

viswalshms commented 7 years ago

I'll give that a shot at my first opportunity and be sure to report back. Thanks for the effort!

Yortw commented 7 years ago

I'm closing this because I believe it's fixed, but if not, please feel free to re-open.