Problem with get user data

Jul 16, 2013 at 2:25 PM
Hello,

Today i started to learn linq to twitter. I hava a problem with get user data I logged succesfully.
twitterCtx.AuthorizedClient.ScreenName and auth.ScreenName returned empty.

Please help me :)
using System;
using Newtonsoft.Json.Linq;
using LinqToTwitter;
using System.Configuration;

public partial class _default : System.Web.UI.Page
{
    private WebAuthorizer auth;
    private TwitterContext twitterCtx;
    protected void Page_Load(object sender, EventArgs e)
    {
        IOAuthCredentials credentials = new SessionStateCredentials();

        if (credentials.ConsumerKey == null || credentials.ConsumerSecret == null)
        {
            credentials.ConsumerKey = ConfigurationManager.AppSettings["twitterConsumerKey"];
            credentials.ConsumerSecret = ConfigurationManager.AppSettings["twitterConsumerSecret"];
        }
        auth = new WebAuthorizer
        {
            Credentials = credentials,
            PerformRedirect = authUrl => Response.Redirect(authUrl)
        };

        if (!Page.IsPostBack)
        {
            auth.CompleteAuthorization(Request.Url);
        }

        twitterCtx = new TwitterContext(auth);

        string screenName = twitterCtx.AuthorizedClient.ScreenName;

        if (auth.IsAuthorized)
        {
            Response.Write("Logged in as " + auth.ScreenName + " - " + screenName);
        }
        else
        {
            Response.Write("You are not authorized from twitter.");
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        auth.BeginAuthorization(Request.Url);
    }
}
Coordinator
Jul 18, 2013 at 8:11 PM
Hi,

I have a LinqToTwitterWebFormsDemo project in the downloadable source code that you can run and compare against your code. The downloads page also has WebForm demo source code. ScreenName is only populated after CompleteAuthorization.

@JoeMayo