Need Help with OAuth

Dec 28, 2010 at 10:56 AM


i'm trying to make a simple console application. It should Authentificate with OAuth and send a "Hello World" Tweet. I already registered the application on and got the consumer key and consumer secret. But i don't know how OAuth in Linq2Twitter works! The documentation didn't helped, because the OAuth pages are empty and samples on the web are based on older builds ( -> in Version 2.0 the Property ConsumerKey doesn't exists anymore?!).

It would be nice if someone would post here how to post a simple "Hello World to Twitter" Tweet in coneolse Application.



Dec 28, 2010 at 3:16 PM

Hi Flixus,

In the source code download there's a console project named LinqToTwitterDemo.  Look in the Program.cs file, which has examples of using LINQ to Twitter with and without OAuth.  Put your ConsumerKey and ConsumerSecret in app.config and step over each statement (you probably don't want to step into the OAuth code) to see how it works.  You'll see a long list of commented statements, such as StatusDemos.Run(), which will have many more examples of how to perform each type of query supported by Twitter.

LINQ to Twitter recently integrated DotNetOpenAuth as its OAuth provider.  However, I recently replaced the old OAuth with a new implementation.  So, the examples in blog posts on  the Web don't work because they're old and only work with older versions of LINQ to Twitter.  It's a continuous balancing act between documentation, new features, and support.  Right now, I'm spending a lot of time on new features, but will circle back to documentation before long.


Dec 28, 2010 at 9:01 PM

Ahhhh nice!!! It works. Thank you.

Just 3 short questions:

- how long the authentificated "session" will be alive? i want to make a service which is checking every x minutes the twitteraccount (i need oauth because he must be able to send status updates etc..). My plan is to authenticate when i start the service first time (press "allow" and enter pincode), create an instance of TwitterContext and use this object until the service crashes or I stop the service for a long time. Am i right?

- is it really required to authenticate with oAuth, when i want to make an application which is tweeting? it's no web app! i don't like it to run the service with a console. :/ but if there's no other way... ok!

- do you got paypal? i'll make a donation. you did a great job. thanks for your support.

Dec 29, 2010 at 2:17 AM

You'll only ever need to authenticate a user one time.  After the first authentication, store the credentials in the database and reuse them anytime you need to load credentials.  If the credentials are already loaded, you can go straight to querying.  Here's a recent discussion where I described the process of doing this:

While the concept of saving credentials to the DB and then reusing them is the same, your situation will be different because of the type of application you're building.  The discussion at the above link centered around ASP.NET MVC, which is stateless and requires more work to build credentials and instantiate TwitterContext on each request.  However, your application is stateful, meaning that you can instantiate TwitterContext and keep a reference to the instance at an appropriate scope that will allow you to reuse the same instance.  As long as you have a reference to the same instance, you won't need to re-authenticate.  There are several scenarios to consider, based on the type of app you're developing, but the same concepts of ensuring your Credentials are populated is the central theme.

I don't have an automated PayPal button, yet, but if you would like to click on my name in this email and use the CodePlex contact form, I'll give you my PayPal information.  I've written 6 books and another way to contribute is by buying my books and providing reviews and ratings on  Thank you.