I have the public calendar in Google and I want to access the list of upcoming events.
I am reading their docs and I am getting confused with OAuth.
I have the public calendars I don't think I need any OAuth.
I am not able to find simple example in Python where I can access the events. Can anyone give me some code example of that? I am not able to find how to start.
You can get an XML or iCalendar feed of the calendar. Since it's a public calendar, there should also be a public feed listed. These do not require OAuth or any other form of authentication if the calendar is public.
Related
I have a public Google Calendar link (which I do not manage), and I would like to extract data from it to my python program. (From there I will myself process the data).
Basically, given a url to a public Google Calendar, I want to parse the events. No need to add or delete events, just read the events and their info. I don't see a reason to log in to my Google account because anyone with the url can view said Calendar from their browser with no sign-in needed.
Couldn't find anything on the web that does specifically this. Thanks!
You need to use authentication. There simply is no way around this. There are several reasons for this, but the main one is that the Google Calendar API has usage limits.
If there is no way to identify the account performing the request, you could create an app that spams the API with so much requests you bring down the Google Calendar API for everyone. Attaching authentication to the requests allows Google to track the usage.
You should use a service account created specifically for this. The best documentation about service accounts and how to use them in python is this one.
Combining this documentation for the Calendar API with the one linked above should get you started.
Note, if you are performing a lot of requests, you might hit the limits mentioned above. You will need to use what is called exponential backoff. The principle is described here. If you want to know about why to use a random value, see this nice blogpost on how to shoot yourself in the foot.
I am new to web programming- I've recently been familiarizing myself with the webapp2 framework. I'm trying to start building a website, and would like users to login to the site with Facebook and I'll need access to their friends list. I've been trying to find a way to do this- I found out about OAUTH2, and I think this may be a way to do this. All the tutorials for python and OAUTH2 that I've found have been using the google API, I'm not sure if it's any different, but I haven't been able to get it to work.
Does anyone have sample code they can post that uses OAUTH2 (or anything else) to get users to sign in through Facebook? Or any good resources that can help me with this?
Your app needs to authorize users with Facebook, since there's where the resources you need are (e.g. friend lists).
This is a classic use of OAuth2 and you don't have a way around it, because FB implements this protocol.
My suggestion is that you look at the Google sample and then adjust it for FB API. The important changes are:
The endpoint URLs (e.g. authorize, token and user profile
The scopes that define the extent of permissions you are requesting (e.g. list of friends)
The user profile (e.g. the information returned by FB on a user: name, e-mail, etc)
This is a very simple sample that does this in Python. It was meant to run in Google App Engine. The only caveat is that it uses our own library to encapsulate the flow. But you can use it to study how the basic protocol works. Run the live demo and turn on dev tools on your browser to see the network activity.
You will notice that OAuth2 is a rather simple protocol, using simple HTTP requests.
I need to programmatically download all of the .ics file from a user's Google Calendar. I wasn't able to find a way to do this using the Google Calendar v3 API but I may have missed something. Does anyone have any tips for how I can do this (in Python)? Thanks!
Since I stumbled upon this from a google search and later found the answer,
use this link:
https://calendar.google.com/calendar/ical/CALENDAR-EMAILADDRESS-HERE/public/basic.ics
If anyone knows how to get from private (by providing api key or whatever) please comment :)
You can do a get request for the following feed:
https://www.google.com/calendar/ical/calendarID/public/basic.ics
The thread has more detail on how to https://groups.google.com/forum/?fromgroups=#!topic/google-calendar-help-dataapi/bUFJLpoz59g
For private calendars it's possible by using the private address
Example:
https://calendar.google.com/calendar/ical/{PRIVATE ADRESS}/basic.ics
See this link for more information about private address: https://support.google.com/calendar/answer/37648?hl=fr#zippy=%2Cadresse-privée
I've been researching and having a hard time trying to figure out how to work my solution out. Basically my end goal is to be able to log into Google Calendar and grab a dates events and work with the information. If possible, be able to use multiple accounts. I've done some research and have come across Google's own API but I just don't know where to start.
This is the API documentation (with python code examples):
https://developers.google.com/google-apps/calendar/v2/developers_guide_protocol
you will need this library:
http://code.google.com/p/gdata-python-client/
more concrete you need to use this class:
http://code.google.com/p/gdata-python-client/source/browse/src/gdata/calendar/client.py
in order to get the data from a users, you will need to have the auth_token for each of them.
I'm not sure if this API allows you to use direct login instead of auth_token.
UPDATE:
current API version is 3: https://developers.google.com/google-apps/calendar/
Google Calendar V3 Python Client
Google Calendar V3 provides an API client that can be authenticated using the following: access_token, refresh_token, client_id, and client_secret
https://github.com/priyadarshy/google-calendar-v3
I'm stuck..
Basically my goal is I want to be able to pull in end user's calendars, and parse their data daily. I don't need any interaction from them, just enough to authenticate them with OAuth. My current solution is a plain text file that it goes through as a dictionary and pulls in the calendar that way, but that's just asking for trouble. I am just getting my hands on OAuth but don't know how I'd use it in my instance.
Take a look at this example for using OAuth2 to access Google Cloud Storage. You should be able to use it with relatively small tweaks to pull Google Calendar data (primarily changing the scope from https://www.googleapis.com/auth/devstorage.full_control to https://www.googleapis.com/auth/calendar
This example is also helpful, showing how to loop over all a user's Google+ activities and print them to the console. Especially take note of how to use from apiclient.discovery import build to build an API object to interacte with the service.
You can also play with the Google Calendar API using the OAuth 2.0 playground tool or look through the API using the APIs explorer.