TwitterRt - Tweeting from within your Windows 8 App

Sign in to queue


Today's Modern UI Monday post is a library by John Michael Hauck, with source too, that makes tweeting from your Windows 8 app almost too simple and easy. And as an added bonus, you not only get the library, but a tutorial on how to use Twitter's API too.

TwitterRt - Tweet from Windows Metro Apps

My goal is to make tweeting from a C# Metro application as easy as possible. To that end, I created a library called TwitterRt.

Install TwitterRt from and add to your existing Metro application:

  1. Install the NuGet Package Manager if you have not already.
  2. Open your Metro application in Visual Studio.
  3. Select Manage NuGet Packages from the Project menu.
  4. Click Online. Search for TwitterRt. Click Install.

To add the ability to tweet from your application, let's say its called MyTwitApp:

  1. Create your own personal twitter account if you don't have one, at
    Now log out of twitter.
  2. Create your application's own twitter account,
    preferably with the name MyTwitApp (or whatever your app is called), at
    1. Navigate to,
      select "Create an app",
      call it "MyTwitApp" (or whatever your app is called)
    2. Make sure to specify (*) read, write and access direct messages.
    3. Make sure to specify a callback url of
      (or whatever your app is called), even if it is not a real web site.
  3. From the Details page of your's MyTwitApp (or whatever your app is called):
    1. Ensure the "Access level" is "Read, write, and direct messages"
    2. Remember the Consumer key, Consumer secret, and Callback URL for step 5.
  4. There is an option on the Details page called "Create my access token".
    Found it? Great! Ignore it.
  5. From your application:
    1. Construct a TwitterRt class, passing the consumer key, consumer secret and callback url found in step 3 above.
    2. Add a call to await GainAccessToTwitter()
      (Yeah, you need to make your method "async")
    3. Run your app so that it makes the call to GainAccessToTwitter()
    4. When confronted with the twitter signin screen that magically appears from within your application, log in to your personal twitter account and click the "authorize button" (you might need to scroll down)
  6. From a web browser:
    1. Log in to twitter using your personal account.
    2. Navigate to to see if your application is listed.
    3. If it is listed, great! If not, I dunno what to tell you.
  7. From your application, call await Tweet("test")
    (Yeah, you need to make your method "async")
  8. Go back to the web browser and see if you tweeted "test".
    If it is there, great! If not, look at the value of Status.


       Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
               Click="OnAuthorize">Authorize Twitter</Button>
               Click="OnTweet">Tweet Now</Button>
               x:Name="_statusTextBlock" />

using System;
using System.Threading.Tasks;
using TwitterRtLibrary;
using Windows.UI.Xaml.Controls;

namespace TwitterRtDemoApp
    public sealed partial class MainPage : Page
        public MainPage()
            TwitterRt = new TwitterRt("consumerKey goes here", "consumerSecret goes here", "callbackUrl goes here");

        private async void OnAuthorize(object sender, Windows.UI.Xaml.RoutedEventArgs args)
            await TwitterRt.GainAccessToTwitter();
            _statusTextBlock.Text = TwitterRt.Status;

        private async void OnTweet(object sender, Windows.UI.Xaml.RoutedEventArgs args)
            await TwitterRt.UpdateStatus("Hello From TwitterRt " + DateTime.Now);
            _statusTextBlock.Text = TwitterRt.Status;

        public TwitterRt TwitterRt { get; private set; }

More Information

Latest TwitterRt binaries reside here:

Latest TwitterRt source resides here:


What I really liked was how John not only talks about his library and how to use it, but how it actually works, the magic behind the library. It provides a great tutorial for communicating with Twitter. Not that you need this anymore now that you have this library, but it still provides some great technical details and we all love knowing how out libraries work, right?

TwitterRT - The Design

This post describes the inner workings of TwitterRT and how it fulfills the Twitter OAUTH API. You do not need to read this if you are just using TwitterRT and do not really care how it works.

There are three major parts to issuing a tweet on behalf of your user:

  • Register your application with Twitter.
    This is a bit involved and not explained in this post.
    Instead, first read Posting To Twitter from Metro in C#.
  • Signing in to Twitter from your application.
    This is more complicated and is described in 3 steps below.
  • Posting Tweets.
    This is pretty easy and described at the end of this post.

Make sure you also check out the other related articles;

The Discussion

Add Your 2 Cents