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

WinRTAuthorizer UnauthorizedAccessException

Dec 20, 2012 at 9:59 PM
Edited Dec 20, 2012 at 10:11 PM

Hi Joe,

I am running into a problem with the WinRTAuthorizer. If the user decides not the go ahead and press the back button saving of the (mostly null) credentials may conflict with loading of the stored credentials file when logging in again and may cause an UnauthorizedAccessException thrown by this line in LoadCredentialsFromStorageFile:

var credentialsString = await FileIO.ReadTextAsync(credentialsFile);

Took a copy of LinqToTwitter yesterday (sorry, still need to install git) to find where this occurs.

I would at least change WinRTAuthorizer to not try to save credentials that are null anyway.

            var user = await twitAuthentication.AuthenticateAsync();
            if (twitAuthentication.OAuthToken != null && twitAuthentication.OAuthTokenSecret != null)
                OAuthTwitter.OAuthToken = twitAuthentication.OAuthToken;
                OAuthTwitter.OAuthTokenSecret = twitAuthentication.OAuthTokenSecret;
                Credentials.ScreenName = user.UserName;
                Credentials.UserId = user.Id;
                Credentials.OAuthToken = twitAuthentication.OAuthToken;
                Credentials.AccessToken = twitAuthentication.OAuthTokenSecret;
BTW ran into a NullReferenceException due to the Log not being initialized when posting. Add a null check in the exception handler of PostToTwitter
if (Log != null)
    Log.Write("Error querying Twitter: " + ex.ToString());

kind regards,


Dec 21, 2012 at 4:00 AM

Hi Roland,

Thanks for the fixes. I just checked them in.