Пример #1
0
        private void LoginBrowser_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (e.Url.ToString().Contains("#"))
            {
                string id="", expires="", token="", get=e.Url.ToString();
                try
                {
                    get = get.Split('#')[1]; //erase trash like http:
                    token = get.Split('&')[0].Split('=')[1]; //take string between = and &
                    expires = get.Split('=')[2].Split('&')[0]; //take expires_in=__&
                    id = get.Split('=')[3];//get user id, its 3 '='
                }
                catch { }

                this.si = new SessionInfo();
                this.si.AppId = this.AppId;
                this.si.Permissions = this.Permissions;
                this.si.Token = token;
                this.si.UserId = Convert.ToInt32(id);
                this.si.Expire = Convert.ToInt32(expires);

                this.LoginInfoReceived = true;
                this.Close();
            }
        }
Пример #2
0
 /// <summary>
 /// Gets the session with browser
 /// </summary>
 /// <returns>SessionInfo with info about user session. Null - if login failed</returns>
 public SessionInfo getSession()
 {
     time = DateTime.Now;
     BrowserAuthorization wnd = new BrowserAuthorization();
     wnd.Permissions = vk_music.Properties.Settings.Default.permissions;
     wnd.AppId = vk_music.Properties.Settings.Default.appid;
     wnd.ShowDialog();
     if (wnd.LoginInfoReceived)
     {
         session = wnd.si;
         saveSession();
         return wnd.si;
     }
     else
     {
         return null;
     }
 }
Пример #3
0
 public SessionManager()
 {
     this.session = new SessionInfo();
 }