Three legged OAuth example using v2.0+ client library

373 views
Skip to first unread message

Devraj Mukherjee

unread,
Mar 22, 2012, 10:32:17 PM3/22/12
to Google Documents List API
Hi all,

I've trying to follow this article
(http://code.google.com/apis/gdata/docs/auth/oauth.html#NoLibrary) and
use Three legged OAuth to authentication against Google docs.

I am using Python (and the Python 2.0+ client library), All examples
referenced from that article use the 1.0 client library.

Anyone aware of a v2.0+ client library example for OAuth out there? I
am nearly there, I manage to get an authentication token, but even
though I assign the token object to the DocsClient, it fails to fetch
a list throwing a gdata.client.Unauthorized: Unauthorized - Server
responded with: 401

Thanks for your time and any resources you can point me to.

Carlyle

unread,
Mar 26, 2012, 1:38:05 AM3/26/12
to google-docum...@googlegroups.com
I would like to know how to do this with PHP. I am new to oAuth.

bump

Ali Afshar

unread,
Mar 26, 2012, 8:33:50 AM3/26/12
to google-docum...@googlegroups.com
Hi Devraj,

You should very much consider using OAuth 2 with the Python client library instead of three-legged OAuth 1.

Alain wrote an article here: http://googleappsdeveloper.blogspot.com/2011/09/python-oauth-20-google-data-apis.html which explains everything you need. In your case you won't need the calendar scope.

You 
--
Ali Afshar | www.googplus.org/ali | Google Developer Relations

Devraj Mukherjee

unread,
Mar 26, 2012, 8:00:15 PM3/26/12
to google-docum...@googlegroups.com
Hi Ali,

On Mon, Mar 26, 2012 at 11:33 PM, Ali Afshar <afs...@google.com> wrote:
>
> You should very much consider using OAuth 2 with the Python client library
> instead of three-legged OAuth 1.
>

Thanks for pointing out Alain's article.

Does OAuth 2 work with regular Gmail accounts as well?

Ali Afshar

unread,
Mar 27, 2012, 11:14:43 AM3/27/12
to google-docum...@googlegroups.com
Hi Devraj,

Yes it works with all accounts, and is a complete replacement for 3-legged OAuth 1.

Regards

Devraj Mukherjee

unread,
Mar 28, 2012, 7:17:03 AM3/28/12
to google-docum...@googlegroups.com
Hi Ali,

Thanks for your responses.

Wondering if there are any examples you know of for installed apps?

Claudio Cherubino

unread,
Mar 28, 2012, 12:10:05 PM3/28/12
to google-docum...@googlegroups.com
Hi Devraj,

The following article contains an example of a Python installed app that uses OAuth 2.0 to access the Provisioning and Email Settings APIs:


You can use that as reference and replace those APIs with the Documents List API.

Claudio

Devraj Mukherjee

unread,
Mar 28, 2012, 6:33:34 PM3/28/12
to google-docum...@googlegroups.com
Hi Claudio,

Thanks for that. I assumed there was an API call that would allow me
to fetch the token (like in OAuth 1).

This example makes it clear, that I can't. Cheers.

Reply all
Reply to author
Forward
0 new messages