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
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 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.
I'm trying to provision (among other things) groups for our Google Apps domain, using python. I'm also attempting to using OAuth to authorise my application. The API documentation for Python seems to be missing or broken links. But from searching through the code, it seems I can't use the new (GDClient) APIs as (among other things) I can't get a list of group owners (which I can do in the older GDataService API). And the API for group settings seems to be either the old GDataService, or the even newer apiclient API, but I can't perform basic group provisioning using that API. So it seems I'm stuck using the GDataService API. However, I can't get my head around how to use OAuth for GDataService objects - I can create an oauth token using oauth2client, but can't authorise a GDataService object using this token.
Any pointers as to where to go from here? I'm struggling to believe how messy this all is
The provisioning API is still on the older GDataService API. It is being replaced by the new API called directory api (check out here https://developers.google.com/admin-sdk/)
If you just want to at least get start and familiar with the OAuth flow. You should check out this documentation for the Python API client library: https://developers.google.com/api-client-library/python/start/installation
Try the quick start. All you have to do is select the API you want to use, and select the platform (I usually just picked command line). Click 'Configure Project'. Make sure you are already logged in you Google Apps account that you used to create your project in API console. Select your API project and then finally download the whole package.
Remember to replace your client secret file and just run the sample python code. It will do all the OAuth flow for you.
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.
I'd like to allow my Google App Engine application to connect to a clients Google Spreadsheet on their Google Drive. I've spent the last two and a half days trying, and I've gotten nowhere. Half of the GAE Python documentation seems to be out of date. For example some of the examples have webapp, and they don't work until I change them to webapp2, but that doesn't always work.
I created a OAuth2.0 thing (not really sure what to call it) at:
https://code.google.com/apis/console/
So now I have a Client ID and Client Secret, but one doc talked about a CONSUMER_KEY and CONSUMER_SECRET. So are they the same or?
I followed the following doc to use OAuth to read my tasks (I know it's a different API), but I couldn't figure out step/Task 3. I'm not sure if I have all of the files/librarys to connect using OAuth. I have the gdata-2.0.17 files, and I know how to connect to the drive and spreadsheets by hard coding the login credentials, but no user is going to give me their credentials.
I don't normally ask for code, or even help, but I'm completely lost with this whole OAuth API/Service.
If someone could post some sample code that uses OAuth 2.0 and webapp2, and that you have tested, that would be awesome.
If someone could link me to a sample GAE Python project that can authenticate with Google's servers and allow it to connect to the users spreadsheets using OAuth 2.0 and webapp2, I'd be over the moon.
A complete example application using Google Drive from GAE is explained in this article.
See Retrieving Authenticated Google Data Feeds with Google App Engine (Python) if you need to access the spreadsheet content.
The samples in this article is using Google Document List API but it could be easily adapted to use spreadsheets scope and spreadsheet client or service.
If you only need to list the files, I would recommend using Drive like #SebastionKreft suggested