Reputation: 5924
I created a new application and registered it with Twitter to get the consumer key, consumer key secret, token, and token secret. I then added a reference to TweetSharp. Next I used the code from https://github.com/danielcrenna/tweetsharp where it says "Authenticating a client application (i.e. desktop)".
The page it always opened had no key in the title bar. I noticed that the oAuthRequestToken in step 1 had two properties for token/token secret, and neither were set. So I manually added lines to set these two. I tried again. This time the Url that opened in the browser looked to be complete.
All I ever see is "Whoa there! The request token for this page is invalid. It may have already been used, or expired because it is too old. Please go back to the site or application that sent you here and try again; it was probably just a mistake."
I've tried recreating the tokens, and sending keys as well as tokens in case I wasn't understanding it. I am completely lost. It can't be this difficult just to get started!
Any ideas?
Upvotes: 2
Views: 998
Reputation: 11
I'm not sure where your problem is, but i will try to help. Here is a sample that i tested and works for me. I got it from the comunity. Don't forget to place the keys in the app.config file.
TwitterClientInfo twitterClientInfo = new TwitterClientInfo();
twitterClientInfo.ConsumerKey = ConsumerKey; //Read ConsumerKey out of the app.config
twitterClientInfo.ConsumerSecret = ConsumerSecret; //Read the ConsumerSecret out the app.config
TwitterService twitterService = new TwitterService(twitterClientInfo);
//Now we need the Token and TokenSecret
//Firstly we need the RequestToken and the AuthorisationUrl
OAuthRequestToken requestToken = twitterService.GetRequestToken();
string authUrl = twitterService.GetAuthorizationUri(requestToken).ToString();
//authUrl is just a URL we can open IE and paste it in if we want
Process.Start(authUrl); //Launches a browser that'll go to the AuthUrl.
//Allow the App
//ask for the pin
//string pin = ...
OAuthAccessToken accessToken = twitterService.GetAccessToken(requestToken, pin);
string token = accessToken.Token; //Attach the Debugger and put a break point here
string tokenSecret = accessToken.TokenSecret; //And another Breakpoint here
twitterService.AuthenticateWith(AccessToken, AccessTokenSecret);
Hope it helps. Good luck.
Upvotes: 1