Authorize with accestoken

Dec 13, 2011 at 10:34 AM
Edited Dec 13, 2011 at 10:35 AM

Hello everyone,

Linq to twitter is relatively new for me and I am facing an issue that I'm not able to resolve.
In my mobile application (MonoTouch) I'm sending the user to twitter to login and authenticate. Everything goes great right here, I'm storing the user's OAuthToken + AccesToken into my database so that I don't have to authenticate the user again.

Now I am facing a problem.. when my user is authenticated and logged in I want to retrieve the OAuthToken + AccesToken from the database and update his status. How am I able to do this? Do I need another PinAuthorizer instance? I tried the following stuff:


			IOAuthCredentials credentials = new InMemoryCredentials();
				credentials.ConsumerKey = "key";
				credentials.ConsumerSecret = "secret";
				credentials.AccessToken = "token";
				credentials.OAuthToken = "oauth from the user";
			authorize = new PinAuthorizer
					Credentials = credentials
				m_twitterCtx = new TwitterContext (authorize, "", "");
                    updateResp => new Thread(() =>
                        switch (updateResp.Status)
                            case TwitterErrorStatus.Success:
                                Status tweet = updateResp.State;
                                User user = tweet.User;
                                UserIdentifier id = user.Identifier;
						Console.WriteLine("user :" + id.ScreenName + " posted status: " + tweet.Text);
                            case TwitterErrorStatus.TwitterApiError:
                            case TwitterErrorStatus.RequestProcessingException:


Sadly that didn't do it for me.. I'm unable to find any documentation regarding this problem(or I couldn't find it).


Dec 13, 2011 at 2:26 PM

Hi Mittchel,

Correct, you need to instantiate a new authorizer with new credentials and populate each property of the Credentials with their values, including OAuthToken and AccessToken.  Then instantiate TwitterContext with the authorizer.

I've created some documentation and have examples in the downloadable source code, which you've probably looked at.  There are a lot of different scenarios to cover with different technologies and I'll be building up the sample library as time goes on.

I'm curious about seeing Linq2Twitter work with MonoTouch. If you click on my profile link and use the contact form, I can take a look.


Dec 14, 2011 at 12:32 PM


Thanks for your response.

I contacted you like you asked and explained my problem in detail. For other MonoTouch users I think it's useful that my problem gets handled here aswell. 
LinqToTwitter works on MonoTouch with some minor modifications, but as I stated in my starting post it goes wrong when I try to update a status with tokens that are saved inside my database. I'm getting a 401 Unauthorized error back, which means 1 of the tokens doesn't match. This is weird, because I'm storing the tokens inside my database and I'm 100% sure that they're correct.

My iPhone application has (of course) one user. Though my twitter application has multiple users, because multiple users can use the twitter integration inside my application.

Probably it's me who's doing something wrong rather than the library limitations on MonoTouch, thus I'm not sure what I'm doing wrong so I hope you could help me out!

Thanks in advance,