From oauth2client.appengine import oauth2decorator_from_clientsecrets ImportError: no module named appengine

I get the following error when trying to start an application

from oauth2client.appengine import oauth2decorator_from_clientsecrets ImportError: No module named appengine 

Here is my main.py code

 import httplib2 import os from google.appengine.ext import webapp from google.appengine.ext.webapp.util import run_wsgi_app from oauth2client.appengine import oauth2decorator_from_clientsecrets CLIENT_SECRETS = os.path.join(os.path.dirname(__file__), 'client_secrets.json') decorator = oauth2decorator_from_clientsecrets(CLIENT_SECRETS, 'https://www.googleapis.com/auth/bigquery') class MainHandler(webapp.RequestHandler): @decorator.oauth_required def get(self): self.response.out.write("Hello Dashboard!\n") application = webapp.WSGIApplication([ ('/', MainHandler), ], debug=True) def main(): run_wsgi_app(application) if __name__ == '__main__': main() 

And here is my app.yaml

 application: hellomydashboard version: 1 runtime: python27 api_version: 1 threadsafe: false handlers: - url: /favicon\.ico static_files: favicon.ico upload: favicon\.ico - url: /oauth2callback script: oauth2client/appengine.py - url: .* script: main.app 
+4
source share
1 answer

The first problem is that you added the / oauth 2callback handler to app.yaml. Please see the documentation on decorators:

https://developers.google.com/api-client-library/python/platforms/google_app_engine?hl=en#Decorators

Or sample code here:

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

As for the import error, have you installed the code for the library in your App Engine project? The easiest way to do this is to download the latest version of google-api-python-client-gae-NN.zip and unzip it directly into your project.

http://code.google.com/p/google-api-python-client/downloads/detail?name=google-api-python-client-gae-1.0.zip&can=2

+4
source

Source: https://habr.com/ru/post/1443848/


All Articles