Creating Authorizer from credentials in WP7 doesn't work

Jul 30, 2012 at 12:41 PM

Hello there! First off, this is a great and easy-to-use library, from what I've seen so far (being a noob at programming).

So, I'm trying to retrieve a user's timeline in a Windows Phone 7.1 app, which works perfectly after going through the authorization process (I'm using your OAuth.xaml page for that). But when loading previously stored credentials into an authorizer, it simply doesn't authenticate against Twitter's servers and returns a WebException with "The remote server returned an error: NotFound." It's the exact same result as passing no authorizer to the TwitterContext constructor at all.

Here's the code I'm using in the MainPage.Loaded event handler:

if (IsolatedStorageHelper.ContainsKeys("TwitterCredentials"))
	var slAuth = new SilverlightAuthorizer(); // tried PinAuthorizer too
	var credentials = new InMemoryCredentials();
	slAuth.Credentials = credentials;
	SharedState.Authorizer = slAuth;

ITwitterAuthorizer auth = SharedState.Authorizer;
if (auth == null || !auth.IsAuthorized)
	NavigationService.Navigate(new Uri("/Views/OAuth.xaml", UriKind.Relative));
	var ctx = new TwitterContext(auth);

	(from tweet in ctx.Status
	 where tweet.Type == StatusType.Home
	 select tweet)
	.AsyncCallback(tweets =>
		Dispatcher.BeginInvoke(() =>
			var timelineTweets =
				(from tweet in tweets
				 select new Tweet
					 RealName = tweet.User.Name,
					 Message = tweet.Text,
					 Avatar = tweet.User.ProfileImageUrl

			Timeline.DataContext = new TweetList(TweetList.Type.Timeline, timelineTweets);

I'm storing the credentials like you're suggesting here, only that I'm calling pinAuth.Credentials.ToString().

Any help is appreciated. Also, it seems like other people here are having difficulty with restoring credentials too, so a small sample would be great!

Jul 30, 2012 at 4:16 PM

Thanks for letting me know, I'll take a look.


Aug 2, 2012 at 12:15 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Aug 5, 2012 at 2:13 AM

I found the bug and fixed it.  I added a new demo to the Samples page:

The approach I took was to implement IOAuthCredentials as a new LinqToTwitter type named IsolatedStorageCredentials, which does the loading and saving to Isolated Storage for you.  Check out the call to Save() on the OAuth.xaml.cs page to see how I initially persist the credentials.

BTW, there's also a Clear() method, just in case you need to use it or are testing.

You can get the fix by either downloading the source code or using the DLL in the sample.  It will show up in the next release, but I haven't scheduled that yet as I have a few more things to do.  At least this will work on WP7 for now.


Aug 5, 2012 at 6:52 AM

Thanks a lot Joe, I downloaded the sample and incoporated the DLL into my project, it works flawlessly now. I know it won't be more than a small sign of appreciation but do you accept donations via PayPal?