本文整理汇总了C#中Google.GData.Client.Service.QueryClientLoginToken方法的典型用法代码示例。如果您正苦于以下问题:C# Service.QueryClientLoginToken方法的具体用法?C# Service.QueryClientLoginToken怎么用?C# Service.QueryClientLoginToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google.GData.Client.Service
的用法示例。
在下文中一共展示了Service.QueryClientLoginToken方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetNewAuthenticationToken
/// <summary>
/// Generates a new Authentication Toklen for AppsService
/// with the specified credentials for accessing provisioning feeds on the specified domain.
/// </summary>
/// <param name="domain">the domain to access</param>
/// <param name="adminEmailAddress">the administrator's email address</param>
/// <param name="adminPassword">the administrator's password</param>
/// <returns>the newly generated authentication token</returns>
public static String GetNewAuthenticationToken(string domain, string adminEmailAddress, string adminPassword)
{
Service service = new Service(AppsNameTable.GAppsService,"apps-"+domain);
service.setUserCredentials(adminEmailAddress, adminPassword);
return service.QueryClientLoginToken();
}
示例2: Login
/// <summary>
/// Login here
/// </summary>
/// <param name="onFinish">Delegate for when Login is done.</param>
/// <param name="email">Users e-mail address</param>
/// <param name="password">Password</param>
/// <param name="captcha">Captcha string if required</param>
/// <param name="status">Status to log in as</param>
public void Login(LoginFinished onFinish, LoginProgressUpdate onUpdate, string email, string password, string captcha, UserStatus status)
{
if(Socket.Connected)
{
Thread t = new Thread(() =>
{
//TODO Need to add a method to handle 2-step signin.
_onLoginFinished = onFinish;
String appName = "skylabs-LobbyClient-" + Version;
Service s = new Service("code", appName);
s.setUserCredentials(email, password);
if(captcha != null && _mCaptchaToken != null)
{
onUpdate.Invoke("Verifying captcha");
if(!String.IsNullOrWhiteSpace(captcha) || !String.IsNullOrWhiteSpace(_mCaptchaToken))
{
s.Credentials.CaptchaToken = _mCaptchaToken;
s.Credentials.CaptchaAnswer = captcha;
}
}
try
{
Debug.WriteLine("Querying Google...");
onUpdate.Invoke("Logging into Google...");
string ret = s.QueryClientLoginToken();
onUpdate.Invoke("Sending login token to Server...");
Debug.WriteLine("Received login token.");
SocketMessage sm = new SocketMessage("login");
sm.AddData("email", email);
sm.AddData("token", ret);
sm.AddData("status", status);
WriteMessage(sm);
onUpdate.Invoke("Waiting for server response...");
}
catch(CaptchaRequiredException ce)
{
_mCaptchaToken = ce.Token;
if(OnCaptchaRequired != null) OnCaptchaRequired.Invoke("https://www.google.com/accounts/DisplayUnlockCaptcha", ce.Url);
}
catch(AuthenticationException re)
{
string cu = (string)re.Data["CaptchaUrl"];
onFinish.Invoke(LoginResult.Failure, DateTime.Now, re.Message);
}
catch(WebException)
{
onFinish.Invoke(LoginResult.Failure, DateTime.Now, "Connection problem.");
}
onFinish.Invoke(LoginResult.WaitingForResponse, DateTime.Now, "");
});
t.Start();
}
}