This project has moved and is read-only. For the latest updates, please go here.

Implementing Linq To Twitter in WPF

Apr 2, 2013 at 5:05 PM

I have been trying to implement linq to twitter using pin authorization , each query I run do I need to enter the pin or is it a one time thing.
if so how do I achieve in a WPF app , are there any demos available using PIN Auth.
Apr 2, 2013 at 9:40 PM

You should generally only need to do PIN authentication with a user one time. After the first time, grab the OAuthToken and Access token that Twitter returns after authorization is complete. Save those tokens and reuse them the next time the user performs any action with Twitter. The first time, you'll only have your ConsumerKey and ConsumerSecret, but you can load all 4 credential tokens on subsequent queries. LINQ to Twitter will know that you've loaded all 4 tokens and work without sending the user through the authorization process again.

I only have one WPF demo on the Samples page so far and I don't think it does OAuth. My goal is to have full documentation and samples for every API on each technology and I'm slowly getting there. However, in the meantime, you might be able to look at the OAuth.xaml and OAuth.xaml.cs pages of the Windows Phone demos. Here's the approach I take:
  1. Detect if the user is currently authorized (has all 4 tokens). This is where you go find the tokens you previously saved, if available.
  2. If so, you're good to go and just perform the L2T operations you need.
  3. If not, navigate to an authentication page.
  4. The authentication page has a browser that you can load via the GoToTwitterAuthorization delegate property of PinAuthorizer.
  5. The user authenticates, writes the PIN into a textbox on the same page as the web browser, and clicks a button to indicate they've entered the pin.
  6. You handle the event by grabbing the pin and completing the authorization process.
  7. After authorization, you grab the credentials and save them for that user.
The Windows Phone example is required to use async calls, but WPF isn't. Hopefully, this will get you going in the right direction.