Alaa Salah
Alaa Salah

Reputation: 885

C# - How to get Twitter Access Tokens for a WPF application?

I'm using Tweetsharp library to get some tweets from one user on Twitter ( it's a celebrity, so it won't be the user of my application ), but I need to fetch two access tokens for this operation. How can I get these tokens? I'll store them in my application settings file.

My problem is I don't know exactly how this has to be done, my application is a WPF app, it isn't ASP.Net which would be easier that WPF to get tokens programatically without any need for the user to type-in his/her tokens manually.

Any ideas or examples ?

Upvotes: 0

Views: 1231

Answers (1)

Sumit Kesarwani
Sumit Kesarwani

Reputation: 573

First you have to sign up @ dev.twitter.com and get the consumer key and consumer secret key.

TwitterService service = new TwitterService("ConsumerKey", "ConsumerSecretKey");

OAuthRequestToken requestToken = service.GetRequestToken();

Uri uri = service.GetAuthorizationUri(requestToken);

Process.Start(uri.ToString());

string verifier = Console.ReadLine();

OAuthAccessToken access = service.GetAccessToken(requestToken, verifier);

service.AuthenticateWith(access.Token, access.TokenSecret);

The above code will give you the two access tokens and show you twitter login screen where you have to enter your twitter username and password.

Hope this will solve problem Thank You!

Upvotes: 0

Related Questions