6

I'm trying to get oauth to work on Google App Engine (GAE), but I'm unable to import the OAuth2Decorator, because it tries to import gflags and fails.

In command line I've ran help('modules') and gflags is listed, and I've ran import os + import gflags + print os.path.dirname(gflags.__file__) and received /Library/Python/2.7/site-packages/python_gflags-2.0-py2.7.egg.

In GAE Dev Console I've ran:

import sys
import os

try:
  import webapp2
  import httplib2
  from oauth2client.appengine import OAuth2Decorator 

except ImportError, e:
  print("The import failed!")
  print(e)

and received:

The import failed!
No module named gflags

gflags is imported by from oauth2client.appengine import OAuth2Decorator, but GAE fails to import gflags every time I run the code.

I'm not sure it makes a difference, but I'm running Mac OS 10.7.5 and python 2.7.1

Dan Holevoet
  • 9,183
  • 1
  • 33
  • 49
Graham Walters
  • 2,054
  • 2
  • 19
  • 30

2 Answers2

6

Sorry, I just recently updated the installation instructions with App Engine specific instructions:

https://developers.google.com/api-client-library/python/start/installation

There is a download specifically for App Engine that contains all the client library code and dependencies, just unzip that file into your project and you should be good to go.

Joe Gregorio
  • 770
  • 4
  • 7
2

You'll need to add the required library files to your App Engine project. From the client library docs, once you've installed the client library run:

$ enable-app-engine-project your_app_directory
Dan Holevoet
  • 9,183
  • 1
  • 33
  • 49
  • I ran that command and I gave me an error saying oauth2client already existed in the directory, which it did because I manually put it there, so I deleted it and reran the command. The problem is that it only copied the `__init__.py` file into the new `oauth2client` directory, and not the rest of the `oauth2client` files, such as the `app engine.py` file. I tried reinstalling `oauth2client` but that didn't work, so I've just manually replaced the folder. Should I have to manually add the files or should it copy all of them over? – Graham Walters Nov 25 '12 at 14:14