Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2738)

Issue 4440067: Add support for OAuth 2.

Can't Edit
Can't Publish+Mail
Start Review
Created:
12 years, 12 months ago by alainv
Modified:
12 years, 12 months ago
CC:
gdata-python-client-library-contributors_googlegroups.com
Visibility:
Public.

Description

This is how the OAuth2Token can be used: [CODE] import gdata.gauth import gdata.client import gdata.calendar.client import gdata.calendar.data token = gdata.gauth.OAuth2Token(client_id='<YOUR_CLIENT_ID>', client_secret='<YOUR_CLIENT_SECRET>', scope='https://www.google.com/calendar/feeds', user_agent='calendar-cmdline-sample/1.0') uri = token.generate_authorize_url() print 'Please visit this URL to authorize the application:' print uri # Get the verification code from the standard input. code = raw_input('What is the verification code? ').strip() token.get_access_token(code) client = gdata.calendar.client.CalendarClient(token.user_agent) # Authorize the client. token.authorize(client) # Get events feed. feed = client.GetCalendarEventFeed() for item in feed.entry: print item.title.text [/CODE]

Patch Set 1 #

Total comments: 19

Patch Set 2 : Add support for OAuth 2. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+361 lines, -20 lines) Patch
M src/gdata/gauth.py View 1 8 chunks +249 lines, -3 lines 0 comments Download
M tests/gdata_tests/gauth_test.py View 12 chunks +112 lines, -17 lines 0 comments Download

Messages

Total messages: 6
alainv
12 years, 12 months ago (2011-04-25 20:11:10 UTC) #1
alainv
Added some code snippet in the patch description. Best, Alain
12 years, 12 months ago (2011-04-26 18:11:24 UTC) #2
Ali Afshar
I like this patch in general. Some small comments. http://codereview.appspot.com/4440067/diff/1/src/gdata/gauth.py File src/gdata/gauth.py (right): http://codereview.appspot.com/4440067/diff/1/src/gdata/gauth.py#newcode146 src/gdata/gauth.py:146: ...
12 years, 12 months ago (2011-04-26 22:01:52 UTC) #3
alainv
12 years, 12 months ago (2011-04-26 22:58:35 UTC) #4
alainv
Thanks Ali! Alain http://codereview.appspot.com/4440067/diff/1/src/gdata/gauth.py File src/gdata/gauth.py (right): http://codereview.appspot.com/4440067/diff/1/src/gdata/gauth.py#newcode146 src/gdata/gauth.py:146: def __init__(self, error_message=None): On 2011/04/26 22:01:52, ...
12 years, 12 months ago (2011-04-26 22:58:59 UTC) #5
Ali Afshar
12 years, 12 months ago (2011-04-27 08:34:06 UTC) #6
LGTM

http://codereview.appspot.com/4440067/diff/1/src/gdata/gauth.py
File src/gdata/gauth.py (right):

http://codereview.appspot.com/4440067/diff/1/src/gdata/gauth.py#newcode146
src/gdata/gauth.py:146: def __init__(self, error_message=None):
On 2011/04/26 22:58:59, alainv wrote:
> On 2011/04/26 22:01:52, Ali Afshar wrote:
> > Is error_message ever omitted to have a default of None?
> 
> It is only used once, not sure what's best to do here. Do you think I should
> remove the default value?

IMO, yes

http://codereview.appspot.com/4440067/diff/1/src/gdata/gauth.py#newcode1117
src/gdata/gauth.py:1117: Args:
On 2011/04/26 22:58:59, alainv wrote:
> On 2011/04/26 22:01:52, Ali Afshar wrote:
> > Some of these arguments are specifically named as part of the OAuth2 spec,
> > perhaps this should be linked?
> > 
> > http://tools.ietf.org/html/draft-ietf-oauth-v2
> 
> I added a link to the OAuth 2.0 with Google APIs above which describes the
> different flows and arguments. Do you want me to add some links here again?

No, not required to add again.

http://codereview.appspot.com/4440067/diff/1/src/gdata/gauth.py#newcode1142
src/gdata/gauth.py:1142: @property
On 2011/04/26 22:58:59, alainv wrote:
> On 2011/04/26 22:01:52, Ali Afshar wrote:
> > Why is this a property not a plain attribute?
> 
> It's to have it read-only.

ok

http://codereview.appspot.com/4440067/diff/1/src/gdata/gauth.py#newcode1211
src/gdata/gauth.py:1211: parts[4] = urllib.urlencode(query)
On 2011/04/26 22:58:59, alainv wrote:
> On 2011/04/26 22:01:52, Ali Afshar wrote:
> > None of this handles repeated query arguments, should it? I'm not sure.
> 
> Not sure either, this was mostly inspired by what have been done on the Google
> API Python client library.

Fair enough to leave I think, but it is a potential source of undefined behavior
if kwargs contains some keys like "scope".

http://codereview.appspot.com/4440067/diff/1/src/gdata/gauth.py#newcode1437
src/gdata/gauth.py:1437: return OAuth2Token(parts[1], parts[2], parts[3],
parts[4], parts[5],
On 2011/04/26 22:58:59, alainv wrote:
> On 2011/04/26 22:01:52, Ali Afshar wrote:
> > Any reason this is not something like (*parts[1:])
> 
> Not at all, I just followed what have been done previously. Want me to modify
> the rest of calls to?

Fine, it is consistent I guess.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b