コード例 #1
0
        public static void ParseUserAccessCookie(string cookieValue, out UserInfo userInfo, out UserAuthInfo userAuthInfo)
        {
            var    bytes            = Convert.FromBase64String(cookieValue);
            var    cookie           = Encoding.ASCII.GetString(bytes);
            var    tokens           = cookie.Split(AuthResponseSplit);
            string oauthToken       = string.Empty;
            string oauthTokenSecret = string.Empty;
            string screenName       = string.Empty;
            string userId           = string.Empty;

            foreach (var token in tokens)
            {
                var kvp = token.Split(AuthResponseTokenSplit);
                if (kvp[0].Equals(OAuthTokenKey))
                {
                    oauthToken = kvp[1];
                }
                else if (kvp[0].Equals(OAuthTokenSecretKey))
                {
                    oauthTokenSecret = kvp[1];
                }
                else if (kvp[0].Equals(OAuthUserIdKey))
                {
                    userId = kvp[1];
                }
                else if (kvp[0].Equals(OAuthUserScreenNameKey))
                {
                    screenName = kvp[1];
                }
            }

            userInfo = new UserInfo
            {
                ScreenName = screenName,
                UserId     = userId
            };

            userAuthInfo = new UserAuthInfo
            {
                UserInfo         = userInfo,
                OAuthToken       = oauthToken,
                OAuthTokenSecret = oauthTokenSecret
            };
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: mikedice/weatheramash
 public static void SetUserAuthInfo(UserAuthInfo userAuthInfo)
 {
     userIdToUserAuthInfo[userAuthInfo.UserInfo.ScreenName] = userAuthInfo;
 }
コード例 #3
0
        public static void ParseUserAccessCookie(string cookieValue, out UserInfo userInfo, out UserAuthInfo userAuthInfo)
        {
            var bytes = Convert.FromBase64String(cookieValue);
            var cookie = Encoding.ASCII.GetString(bytes);
            var tokens = cookie.Split(AuthResponseSplit);
            string oauthToken = string.Empty;
            string oauthTokenSecret = string.Empty;
            string screenName = string.Empty;
            string userId  = string.Empty;

            foreach(var token in tokens)
            {
                var kvp = token.Split(AuthResponseTokenSplit);
                if (kvp[0].Equals(OAuthTokenKey))
                {
                    oauthToken = kvp[1];
                }
                else if (kvp[0].Equals(OAuthTokenSecretKey))
                {
                    oauthTokenSecret = kvp[1];
                }
                else if (kvp[0].Equals(OAuthUserIdKey))
                {
                    userId = kvp[1];
                }
                else if (kvp[0].Equals(OAuthUserScreenNameKey))
                {
                    screenName = kvp[1];
                }
            }

            userInfo = new UserInfo
            {
                ScreenName = screenName,
                UserId = userId
            };

            userAuthInfo = new UserAuthInfo
            {
                UserInfo = userInfo,
                OAuthToken = oauthToken,
                OAuthTokenSecret = oauthTokenSecret
            };
        }