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; } }
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); } } }
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; }