本文整理汇总了C#中Google.GData.Calendar.CalendarService.QueryClientLoginToken方法的典型用法代码示例。如果您正苦于以下问题:C# CalendarService.QueryClientLoginToken方法的具体用法?C# CalendarService.QueryClientLoginToken怎么用?C# CalendarService.QueryClientLoginToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Google.GData.Calendar.CalendarService
的用法示例。
在下文中一共展示了CalendarService.QueryClientLoginToken方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: checkPw
// Validates a username/pass by attempting to login to calendar
public static bool checkPw(string username, string password)
{
GDataGAuthRequestFactory authFactory = new GDataGAuthRequestFactory("cl", "Seadragon");
authFactory.AccountType = "HOSTED";
CalendarService client = new CalendarService(authFactory.ApplicationName);
client.RequestFactory = authFactory;
client.setUserCredentials(username + "@" + DOMAIN, password);
try
{
client.QueryClientLoginToken(); // Authenticate the user immediately
}
catch (WebException) // Invalid login
{
return false;
}
return true;
}
示例2: Button_Click_1
/// <summary>
/// 同期
/// </summary>
private void Button_Click_1(object sender, RoutedEventArgs e)
{
//各設定保存
XML xl = new XML();
DataSet ds = new DataSet();
DataTable dtb;
dtb = ds.Tables.Add("data");
dtb.Columns.Add("cal1",Type.GetType("System.String"));
dtb.Columns.Add("cal2", Type.GetType("System.String"));
dtb.Columns.Add("id", Type.GetType("System.String"));
dtb.Columns.Add("pass", Type.GetType("System.String"));
dtb.Rows.Add(new object[] {tbCal1.Text,tbCal2.Text,tbID.Text,tbPASS.Text});
xl.Save(System.Environment.CurrentDirectory + "/data.xml", ds);
// カレンダーサービスを作成
CalendarService service = new CalendarService("companyName-applicationName-1");
// 認証設定
service.setUserCredentials(tbID.Text, tbPASS.Text);
// 認証結果の確認
try
{
// ここで例外がthrowされなければOK
// 処理に少し時間がかかる
var token = service.QueryClientLoginToken();
}
catch (InvalidCredentialsException ex)
{
// 認証に失敗している
MessageBox.Show(ex.Message);
service = null;
}
// 取得条件設定
for (int year = 2014; year < 2021; year++)
{
//ファイルを開く
EXCEL EX = new EXCEL();
EX.Open(year.ToString());
for (int calNo = 1; calNo < 3; calNo++)
{
EventQuery query = new EventQuery();
if (calNo == 1)
{
query.Uri = new Uri("https://www.google.com/calendar/feeds/" + tbCal1.Text + "/private/full");
}
else
{
query.Uri = new Uri("https://www.google.com/calendar/feeds/" + tbCal2.Text + "/private/full");
}
query.StartTime = new DateTime(year, 1, 1);
query.EndTime = new DateTime(year, 12, 31);
query.SortOrder = CalendarSortOrder.descending;
//query.SingleEvents = true;
// 取得して表示
EventFeed feeds = service.Query(query);
IEnumerable<EventEntry> entries = feeds.Entries.Cast<EventEntry>();
foreach (EventEntry entry in entries)
{
//ファイルに書き込み
EX.Write(entry.Times.First().StartTime.Month, entry.Times.First().StartTime.Day,
entry.Times.First().StartTime.TimeOfDay.ToString(), entry.Locations.First().ValueString, entry.Title.Text, calNo);
}
}
//ファイル保存
EX.Save(year.ToString());
//ファイルを閉じる
EX.Close();
}
}
示例3: GetCalendarService
private CalendarService GetCalendarService(EventQuery query, string eventId, DateTime startDateTime, DateTime endDateTime)
{
query.Uri = CalendarUri;
query.Uri = new Uri(string.Concat(query.Uri.ToString(), !string.IsNullOrEmpty(eventId) ? string.Concat("/", eventId) : string.Empty));
query.StartTime = startDateTime;
query.EndTime = endDateTime;
var calendarService = new CalendarService(_applicationName);
calendarService.setUserCredentials(_googleUsername, _googlePassword);
calendarService.QueryClientLoginToken();
return calendarService;
}
示例4: GetAuthToken
private static string GetAuthToken()
{
if (GoogleCalendarAuthToken.IsExpired())
{
var service = new CalendarService("GoogleCalendarReminder");
service.setUserCredentials(Account.Default.Username
, SecureStringUtility.SecureStringToString(Account.Default.Password));
try
{
GoogleCalendarAuthToken.AuthToken = service.QueryClientLoginToken();
}
catch (CaptchaRequiredException ex)
{
// TODO: CDA - http://code.google.com/googleapps/faq.html
MessageBox.Show(ex.Message, ex.GetType().ToString());
//https://www.google.com/accounts/UnlockCaptcha
return null;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().ToString());
return null;
}
}
return GoogleCalendarAuthToken.AuthToken;
}