简体   繁体   中英

How do I get Google Calendar feed from user's access token?

Using OAuth I do get access token from Google. The sample that comes with Google and even this one:

http://code.google.com/p/google-api-dotnet-client/source/browse/Tasks.SimpleOAuth2/Program.cs?repo=samples

show how to use Tasks API. However, I want to use Calendar API. I want to get access to user's calendar. Can anybody tell me how do I do that?

Take a look at the samples:
Getting Started with the .NET Client Library
On the right side of the page linked above there is a screen shot showing the sample projects contained in the Google Data API solution . They proofed to be very helpful (I used them to start my own Google Calendar application).

I recommend keeping both your own solution and the sample solution open. This way you can switch between the examples and your own implementation.

I also recommend to use the NuGet packages:

  • Google.GData.AccessControl
  • Google.GData.Calendar
  • Google.GData.Client
  • Google.GData.Extensions
  • and more ...

This way you easily stay up to date.


Sample to get the users calendars:

public void LoadCalendars()
{
    // Prepare service
    CalendarService service = new CalendarService("Your app name");
    service.setUserCredentials("username", "password");

    CalendarQuery query = new CalendarQuery();
    query.Uri = new Uri("https://www.google.com/calendar/feeds/default/allcalendars/full");
    CalendarFeed calendarFeed = (CalendarFeed)service.Query(query);

    Console.WriteLine("Your calendars:\n");
    foreach(CalendarEntry entry in calendarFeed.Entries)
    {
        Console.WriteLine(entry.Title.Text + "\n");
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM