Example #1
0
        /// <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);
        }
Example #2
0
        /// <summary>
        /// Checks the incoming web request to see if it carries a Flickr authentication response,
        /// and provides the user's Flickr screen name and unique id if available.
        /// </summary>
        /// <param name="screenName">The user's Flickr screen name.</param>
        /// <param name="userId">The user's Flickr unique user ID.</param>
        /// <returns>
        /// A value indicating whether Flickr authentication was successful;
        /// otherwise <c>false</c> to indicate that no Flickr response was present.
        /// </returns>
        public static bool TryFinishSignInWithFlickr(out string screenName, out string userId, out string access_token)
        {
            screenName   = null;
            userId       = "";
            access_token = "";

            var response = FlickrSignIn.ProcessUserAuthorization();

            if (response == null)
            {
                return(false);
            }

            access_token = response.AccessToken;
            screenName   = response.ExtraData["fullname"];
            userId       = response.ExtraData["user_nsid"];

            // 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://flickr.com/{0}#{1}", screenName, userId);

            return(true);
        }