1

I need to verify that user is successfully authenticated or not to his/her twitter account by using linqtotwitter library.Normally iam able to login into the twitter account by opening the webview. but i am not able to find whether he/she is authenticated. Here is my code.

       var auth = new WinRtAuthorizer
        {
            Credentials = new LocalDataCredentials
            {
                ConsumerKey = Constants.TWITTER_CONSUMERKEY,
                ConsumerSecret = Constants.TWITTER_CONSUMERSECRET
            },
            UseCompression = true,
            Callback = new Uri("http://linqtotwitter.codeplex.com/")
        };

        if (auth == null || !auth.IsAuthorized)
        {
            await auth.AuthorizeAsync();
        }

         twitterCtx = new TwitterContext(auth);

i am able to get the twitter context but iam not able to find whether login is succeed or not. once user is succeed i need to open popup. could any please help me how can we do this.

raj
  • 743
  • 6
  • 21

1 Answers1

1

You can use Account/VerifyCredentials, something like this:

        var accounts =
            from acct in twitterCtx.Account
            where acct.Type == AccountType.VerifyCredentials
            select acct;
Joe Mayo
  • 7,501
  • 7
  • 41
  • 60
  • Thanks for your Response. Actually i am new to c# and windows8 development. After adding this code. it was asking me to add the reference file because it gave me suggestion that(could not find an implementation of the query pattern for source type 'linqtotwitter'; 'where' not found. are you missing a reference or a using directive for "system.linq" ). Then i included System.linq, Iam able to run the code but i dont know with the help of accounts variable how can i check whether user is authenticated or not. please provide your feedback thanks in advance... – raj Apr 08 '13 at 06:57
  • Here's a link to the documentation: https://linqtotwitter.codeplex.com/wikipage?title=Verifying%20Credentials. In .NET, 4xx and 5xx HTTP results raise a WebException. In the case of Account/VerifyCredentials, the Twitter API returns a 401 Unauthorized. Therefore, you should wrap this call in a try/catch. If the call succeeds, you'll have a valid Account object. Otherwise, you can catch the exception. – Joe Mayo Apr 08 '13 at 20:38