ฉันได้รับข้อผิดพลาดนี้ขณะพยายามเรียกใช้แอปพลิเคชันคอนโซล c# ของฉัน... ฉันกำลังพยายามเรียก google calender api v3 เพื่อดึงข้อมูลปฏิทินและเพิ่มกิจกรรมลงในปฏิทิน ตามโค้ดตัวอย่างจาก google-api-dotnet-client ฉันกำลังทำสิ่งนี้ ( https://code.google.com/p/google-api-dotnet-client/source/browse/CalendarVB.ConsoleApp/Program.vb?repo=samples ) นี่คือโค้ด vb.net ฉันใช้ตัวอย่างนี้หลังจากแปลงเป็นโค้ด c#
นี่คือรหัสของฉัน:
class Program
{
static void Main(string[] args)
{
try
{
new Program().Run().Wait();
}
catch (AggregateException ex)
{
foreach (var e in ex.InnerExceptions)
{
Console.WriteLine("ERROR: " + e.Message);
}
}
}
private async Task Run()
{
UserCredential credential;
IList<string> scopes = new List<string>();
CalendarService service;
scopes.Add(CalendarService.Scope.Calendar);
using (var stream = new FileStream("client_secrets.json", FileMode.Open, FileAccess.Read))
{
// problem occuring during executing this statement.
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
scopes,
"user", CancellationToken.None, new FileDataStore("Calender.SampleApp") );
}
BaseClientService.Initializer initializer = new BaseClientService.Initializer();
initializer.HttpClientInitializer = credential;
initializer.ApplicationName = "C# Calendar Sample";
service = new CalendarService(initializer);
Event newEvent = new Event();
newEvent.Summary = "Appointment";
newEvent.Description = "Need to meet my Uncle";
IList<EventReminder> reminders = new List<EventReminder>();
reminders.Add(new EventReminder { Method = "sms", Minutes = 10 });
newEvent.Reminders = new Event.RemindersData { UseDefault = false, Overrides = reminders };
newEvent.Recurrence = new String[] { "DTSTART;TZID=Bangladesh Standard Time:20140124T163000;RRULE:FREQ=DAILY" };
IList<EventAttendee> attendees = new List<EventAttendee>();
attendees.Add(new EventAttendee { Email = "[email protected]", Organizer = true, DisplayName = "Hannan" });
newEvent.Attendees = attendees;
newEvent.GuestsCanInviteOthers = false;
newEvent.GuestsCanModify = false;
newEvent.GuestsCanSeeOtherGuests = false;
newEvent.Location = "Dhaka, Bangladesh";
newEvent.Start = new EventDateTime { DateTime = DateTime.Now, TimeZone = "Bangladesh Standard Time" };
Event recurringEvent = service.Events.Insert(newEvent, "primary").Execute();
var list = await service.CalendarList.List().ExecuteAsync();
}
}
นี่คือ URI การเปลี่ยนเส้นทางของฉันในโครงการ GoogleDevelopers Console
Redirect URIs: http://localhost:7744/authorize/
และนี่คือข้อความแสดงข้อผิดพลาดที่แสดงในเบราว์เซอร์
ฉันไม่พบวิธีแก้ไขปัญหานี้ ความช่วยเหลือบางอย่างจะได้รับการชื่นชม ฉันยังค้นหาโพสต์ realted ทั้งหมดใน stackoverflow ด้วย แต่ฉันไม่พบวิธีแก้ปัญหา