J'obtiens l'erreur suivante en essayant d'exécuter mon application
from oauth2client.appengine import oauth2decorator_from_clientsecrets
ImportError: No module named appengine
Voici mon code main.py
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()
Et voici mon 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
Réponses:
4 pour la réponse № 1Le premier problème est que vous avez ajouté le gestionnaire / oauth2callback à app.yaml. S'il vous plaît voir la documentation ici sur les décorateurs:
https://developers.google.com/api-client-library/python/platforms/google_app_engine?hl=en#Decorators
Ou l'exemple de code ici:
http://code.google.com/p/google-api-python-client/source/browse/samples/appengine/main.py
En ce qui concerne l'erreur d'importation, avez-vous installé le codepour la bibliothèque dans votre projet App Engine? Le moyen le plus simple est de télécharger la dernière version de google-api-python-client-gae-NN.zip et de la décompresser directement dans votre projet.