1

I am confused about Google API Authorization and what type is needed.

I am trying to build a python application that can put events on my google calendar. Note that I want events on MY calendar and only MY Calendar. This will run on a server as a back-end for a django appllcation. I am not at all trying to access any other user's data or calendars.

Example: User puts in a service request. I tell the user thanks for the request and then I put a calendar event on my calendar.

I tried the Calendar API OAuth model client ID for web applications and it seems to be asking permission to access the requesting users data. Correct?

Since I log into my google account with a username and password and I get access my profile and calendar, can my application do the same on my account?

How to accomplish this? And what Google API authorization do I need? Any simple examples?

2 Answers 2

0

The recommended approach for authorization to Google APIs is to use OAuth 2. Google provides standalone libraries for OAuth 2 in a variety of languages (such as Python), as well as more comprehensive client libraries (see the Python library) that assist with using OAuth 2 with Google APIs such as the Calendar API.

Using a username and password pair is generally referred to as ClientLogin when it's in the context of Google APIs. This practice is deprecated and strongly discouraged.

With that out of the way, there are simple instructions for using Calendar API v3 with the Python client library on the Google Developers site. However, these instructions are tailored for an application that runs on the command line versus one that operates on a web server, because conceptually and programmatically, this is much simpler to grasp. I would suggest trying this sample first, even though it doesn't do exactly what you want.

There isn't an OAuth 2 on App Engine sample that I'm aware of, but there is an example using the Google+ APIs that is included in the client library samples.

The critical piece of this example, authorizing the user, is nearly identical between an application that uses Google+ APIs versus the Calendar API. The biggest differences will be in the access your application requests on behalf of the user (the scope), which will be something like:

https://www.googleapis.com/auth/calendar

instead of:

https://www.googleapis.com/auth/plus.me

and of course the actual calls to the API, which are described in detail in the Calendar API documentation reference. If you tried the simple Calendar API example I linked above, you should be able to apply what you learned there, with the OAuth 2 setup instructions from the Google+ sample, to do what you want.

0

I wrote a blog post about this last year with sample Python/Django code:

http://www.dannyroa.com/2011/09/26/sign-in-with-google-get-user-info-from-google-profile/

You need to change the scope to use the Calendar API.

You can play with the Calendar API at https://code.google.com/apis/explorer/#_s=calendar&_v=v3.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.