Drive SDK Example Error

364 views
Skip to first unread message

Bob Hancock

unread,
Sep 10, 2012, 8:30:14 PM9/10/12
to google-api-p...@googlegroups.com
I cut and pasted the example into a file called test.py and supplied my credentials from the API Console.  The example code at https://developers.google.com/drive/quickstart#install_the_google_client_library generates the error:

flow = OAuth2WebServerFlow(settings.CLIENT_ID, settings.CLIENT_SECRET, settings.OAUTH_SCOPE)
-->  authorize_url = flow.step1_get_authorize_url()

ValueError: The value of redirect_uri must not be None.
File "/local/src/meetup-rsvp/test.py", line 21, in <module>
  authorize_url = flow.step1_get_authorize_url()
File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 120, in positional_wrapper
  return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 1070, in step1_get_authorize_url
  raise ValueError('The value of redirect_uri must not be None.')

Joe Gregorio

unread,
Sep 10, 2012, 10:07:03 PM9/10/12
to google-api-p...@googlegroups.com
Hey Bob,
Sorry you are having issues with that sample.

To get that working you can pass in the redirect uri either in
step1_get_authorize_url()
or, the preferred approach, pass it in via the constructor:

http://google-api-python-client.googlecode.com/hg/docs/epy/oauth2client.client.OAuth2WebServerFlow-class.html#__init__

Since this is a command-line app you will want to set the redirect_uri
to: 'urn:ietf:wg:oauth:2.0:oob'. I will file a bug internally to
get the sample in the docs updated.

The handling of OAuth 2.0 in that sample is intentionally kept short
to get the sample on a single page. If
you are building a command-line app for everyday use I'd suggest
looking at some of the samples in the
google-api-python-client library, for example the Google+ sample:

http://code.google.com/p/google-api-python-client/source/browse/samples/plus/plus.py

This keeps the client_id and client_secret in a separate file,
client_secrets.json. You can also
look at the keyring sample, which stores the final generated
credentials in your keyring software. Note
that you'll need the python keyring library installed to use it:

http://code.google.com/p/google-api-python-client/source/browse/#hg%2Fsamples%2Fkeyring

Thanks,
-joe

Ali Afshar

unread,
Sep 11, 2012, 11:49:03 AM9/11/12
to google-api-p...@googlegroups.com
Thanks for raising this. I am just fixing the documentation and will let you know when it is updated.

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

Ali Afshar

unread,
Sep 11, 2012, 12:08:47 PM9/11/12
to google-api-p...@googlegroups.com
Documentation has been fixed.

Bob Hancock

unread,
Sep 11, 2012, 2:14:25 PM9/11/12
to google-api-p...@googlegroups.com
Checked it out and it works.
Reply all
Reply to author
Forward
0 new messages