/// <summary> /// Checks the incoming web request to see if it carries a Twitter authentication response, /// and provides the user's Twitter screen name and unique id if available. /// </summary> /// <param name="screenName">The user's Twitter screen name.</param> /// <param name="userId">The user's Twitter unique user ID.</param> /// <returns> /// A value indicating whether Twitter authentication was successful; /// otherwise <c>false</c> to indicate that no Twitter response was present. /// </returns> public static bool TryFinishSignInWithTwitter(out string screenName, out int userId) { screenName = null; userId = 0; var response = TwitterSignIn.ProcessUserAuthorization(); if (response == null) { return(false); } screenName = response.ExtraData["screen_name"]; userId = int.Parse(response.ExtraData["user_id"]); return(true); }
/// <summary> /// Checks the incoming web request to see if it carries a Twitter authentication response, /// and provides the user's Twitter screen name and unique id if available. /// </summary> /// <param name="screenName">The user's Twitter screen name.</param> /// <param name="userId">The user's Twitter unique user ID.</param> /// <returns> /// A value indicating whether Twitter authentication was successful; /// otherwise <c>false</c> to indicate that no Twitter response was present. /// </returns> public static bool TryFinishSignInWithTwitter(out string screenName, out int userId) { screenName = null; userId = 0; var response = TwitterSignIn.ProcessUserAuthorization(); if (response == null) { return(false); } XDocument xml = VerifyCredentials(TwitterSignIn, response.AccessToken); XPathNavigator nav = xml.CreateNavigator(); screenName = nav.SelectSingleNode("/user/screen_name").Value; userId = int.Parse(nav.SelectSingleNode("/user/id").Value); return(true); }
/// <summary> /// Checks the incoming web request to see if it carries a Twitter authentication response, /// and provides the user's Twitter screen name and unique id if available. /// </summary> /// <param name="screenName">The user's Twitter screen name.</param> /// <param name="userId">The user's Twitter unique user ID.</param> /// <returns> /// A value indicating whether Twitter authentication was successful; /// otherwise <c>false</c> to indicate that no Twitter response was present. /// </returns> public static bool TryFinishSignInWithTwitter(out string screenName, out int userId) { screenName = null; userId = 0; var response = TwitterSignIn.ProcessUserAuthorization(); if (response == null) { return(false); } screenName = response.ExtraData["screen_name"]; userId = int.Parse(response.ExtraData["user_id"]); // If we were going to make this LOOK like OpenID even though it isn't, // this seems like a reasonable, secure claimed id to allow the user to assume. OpenId.Identifier fake_claimed_id = string.Format(CultureInfo.InvariantCulture, "http://twitter.com/{0}#{1}", screenName, userId); return(true); }