ScreenName and UserID are null in case of Authenticated User

Jan 28, 2013 at 12:37 PM

I am using following LINQ queries to fetch screenname/userid of an authenticated user:


Here I am using a valid TwitterContext-
var queryResponse =                         from tweet in twitterCtx.User                         where tweet.Type == UserType.Show && tweet.ScreenName == twitterCtx.AuthorizedClient.ScreenName                         select tweet;

var queryResponse =
                        from tweet in twitterCtx.User
                        where tweet.Type == UserType.Show && tweet.ScreenName == twitterCtx.AuthorizedClient.UserId
                        select tweet;

Here I am using valid Auth object-

var
 queryResponse =                         from tweet in twitterCtx.User                         where tweet.Type == UserType.Show && tweet.ScreenName == Auth.ScreenName                         select tweet;

var queryResponse =
                        from tweet in twitterCtx.User
                        where tweet.Type == UserType.Show && tweet.ScreenName == Auth.UserId
                        select tweet;
In all the cases I am getting Null for both screenname and userid. Kindly advice.
Coordinator
Jan 28, 2013 at 3:30 PM
Edited Jan 28, 2013 at 3:31 PM

Hi,

The Authorizer's ScreenName and UserID are only populated when the user does a full OAuth login. So, if you load the authorizer with credentials that were obtained from a previous authorization, ScreenName and UserID aren't loaded either. Here are a couple options:

  1. Query VerifyCredentials and examine the Account.User.Identifier that's returned.
  2. If you already know who the user is, save their ScreenName and UserID when they do OAuth authentication and retrieve the values when you need to perform a query.

@JoeMayo

Jan 29, 2013 at 7:38 AM
Thanks Joe, it worked.


From: [email removed]
To: [email removed]
Date: Mon, 28 Jan 2013 07:30:15 -0800
Subject: Re: ScreenName and UserID are null in case of Authenticated User [LinqToTwitter:431091]

From: JoeMayo
Hi,
The Authorizer's ScreenName and UserID are only populated when the user does a full OAuth login. So, if you load the authorizer with credentials that were obtained from a previous authorization, ScreenName and UserID aren't loaded either. Here are a couple options:
  1. Query VerifyCredentials and examine the Account.User.Identifier that's returned.
  2. If you already know who the user is, save their ScreenName and UserID when they do OAuth authentication and retrieve the values when you need to perform a query.
@JoeMayo
Read the full discussion online.
To add a post to this discussion, reply to this email (LinqToTwitter@discussions.codeplex.com)
To start a new discussion for this project, email LinqToTwitter@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Jun 24, 2013 at 12:43 PM
I ran against this problem today, we're using the Single User mode.

I did note that even using this mode, the Status.User.Identifier is populated, so you can get the ScreenName from that object, instead of User.ScreenName; perhaps this is a change in the latest code release ?

However, for our purposes, we're trying to spit out JSON that looks like the results from the V1 API, as we've got lots of scripts that call it, and so I'm using LinqToTwitter and NancyFX as a Proxy basically.
Coordinator
Jun 24, 2013 at 6:51 PM
Hi Skogenik,

The Identifier property is by design, so that I don't overwrite your original input parameters when you get the response back. Anything that you see listed as an input in the documentation will remain as-is when the query returns.

@JoeMayo