Ejemplo n.º 1
0
        private void VerifyAndRefreshCredentials(TransientCredentials tc)
        {
            GDataCredentials gc = GDataCredentials.FromCredentials(tc);

            if (gc.IsValid(tc.Username, tc.Password, GDataCredentials.BLOGGER_SERVICE_NAME))
            {
                return;
            }
            else
            {
                bool showUI = !BlogClientUIContext.SilentModeForCurrentThread;
                gc.EnsureLoggedIn(tc.Username, tc.Password, GDataCredentials.BLOGGER_SERVICE_NAME, showUI);
                return;
            }
        }
Ejemplo n.º 2
0
        public Authorization Authenticate(string challenge, WebRequest request, ICredentials credentials)
        {
            if (!challenge.StartsWith("GoogleLogin ", StringComparison.OrdinalIgnoreCase))
            {
                return(null);
            }

            HttpWebRequest httpRequest = (HttpWebRequest)request;

            string service;
            string realm;

            ParseChallenge(challenge, out realm, out service);
            if (realm != "http://www.google.com/accounts/ClientLogin")
            {
                return(null);
            }

            NetworkCredential cred = credentials.GetCredential(request.RequestUri, AuthenticationType);

            string auth = _gdataCred.GetCredentialsIfValid(cred.UserName, cred.Password, service);

            if (auth != null)
            {
                return(new Authorization(auth, true));
            }
            else
            {
                try
                {
                    _gdataCred.EnsureLoggedIn(cred.UserName, cred.Password, service, !BlogClientUIContext.SilentModeForCurrentThread);
                    auth = _gdataCred.GetCredentialsIfValid(cred.UserName, cred.Password, service);
                    if (auth != null)
                    {
                        return(new Authorization(auth, true));
                    }
                    else
                    {
                        return(null);
                    }
                }
                catch (Exception e)
                {
                    Trace.Fail(e.ToString());
                    return(null);
                }
            }
        }
Ejemplo n.º 3
0
        public bool Login(string username, string password)
        {
            using (new WaitCursor())
            {
                try
                {
                    _username = username;
                    _password = password;
                    TransientCredentials creds = new TransientCredentials(username, password, null);
                    _credentials = GDataCredentials.FromCredentials(creds);
                    _credentials.EnsureLoggedIn(username, password, GDataCredentials.YOUTUBE_SERVICE_NAME, true, GDataCredentials.YOUTUBE_CLIENT_LOGIN_URL);
                }
                catch (Exception)
                {
                    _credentials = null;
                }
            }

            OnLoginStatusChanged();
            return IsLoggedIn;
        }