private void GetSessionData(HttpResult accessContent)
		{
			SessionData = new OAuthSessionInfo();

			string[] fragments = accessContent.ResponseUri.Fragment.Substring(1).Split('&');
			foreach (string fragment in fragments)
			{
				string[] fragmentNameValue = fragment.Split('=');
				switch (fragmentNameValue[0])
				{
					case "access_token":
						SessionData.Token = fragmentNameValue[1];
						break;
					case "expires_in":
						SessionData.Expire = int.Parse(fragmentNameValue[1]);
						break;
					case "user_id":
						SessionData.UserId = int.Parse(fragmentNameValue[1]);
						break;
				}
			}
		}
Exemple #2
0
        private void LoginBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (e.Url.ToString().Contains("#"))
            {
                Regex r = new Regex(@"\#(.*)");
                string[] json = r.Match(e.Url.ToString()).Value.Replace("#","").Split('&');
                Hashtable h = new Hashtable();
                foreach (string str in json)
                {
                    string[] kv = str.Split('=');
                    h[kv[0]] = kv[1];
                }

                this.SessionData = new OAuthSessionInfo();
                this.SessionData.AppId = this.AppId;
                this.SessionData.Scope = this.Scope;
                this.SessionData.Token = (string)h["access_token"];
                this.SessionData.Expire = Convert.ToInt32(h["expires_in"]);
                this.SessionData.UserId = Convert.ToInt32(h["user_id"]);

                this.Authenticated = true;
                this.Close();
            }
        }