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 }; }
public static void SetUserAuthInfo(UserAuthInfo userAuthInfo) { userIdToUserAuthInfo[userAuthInfo.UserInfo.ScreenName] = userAuthInfo; }
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 }; }