WinRT (Metro) Persistence Question - Newbie

May 24, 2012 at 2:16 AM

I am successfully using PinAuthorizer in WinRT.

When restarting my app, what should I save from the Pin authorization (OAuthToken, AccessTaken, ID, ScreenName, UserID, etc.) to my RoamingSettings?

Then, when restarting, how do I reconstruct the authorizer?  Do I construct an OAuthAuthorizer or a SingleUserAuthorizer.  I assume an OAuthAuthorizer, but I'm not sure which properties I need to set.  Any suggestions would be appreciated.

Coordinator
May 24, 2012 at 3:38 AM

After you successfully complete authorization, you can get the credentials from the AuthorizedClient property of your TwitterContext instance.  i.e.

twitterCtx.AuthorizedClient.Credentials ...

You can either grab each Credentials property individually, or use the Load and ToString methods to handle them as a comma-separated value string.  Once you have all the credentials, save them.  On subsequent queries, grab the saved credentials and load all four into a new ITwitterAuthorizer, assign that authorizer to a TwitterContext, and then work with Twitter like normal.  There isn't a need to re-authorize when you have all four credentials because Twitter keeps the OAuthToken and AccessToken.

You can keep using the same type of authorizer as initially used for the first authentication.

For more information on security, OAuth, and which authorizers you should use, visit the Securing Your Applications page in the LINQ to Twitter documentation.

Joe