Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何将OAuth2Decorator与Google云存储结合使用?_Python_Google App Engine_Google Api Python Client_Google Cloud Storage - Fatal编程技术网

Python 如何将OAuth2Decorator与Google云存储结合使用?

Python 如何将OAuth2Decorator与Google云存储结合使用?,python,google-app-engine,google-api-python-client,google-cloud-storage,Python,Google App Engine,Google Api Python Client,Google Cloud Storage,我遵循这一点是为了将我的应用程序引擎python web服务与Google storage连接起来,特别是为了能够使用文件API。我看了buzz的例子,但似乎对我不起作用。我需要web服务在后台进行授权,以便能够从存储中检索我的文件 我试图使用decorator来传递我的客户id和客户机密,但这个过程对我来说并不十分清楚。谁能在这个过程中提供一个例子或详细说明一点 编辑:我正在使用Python2.7运行时。这可能不是最直接的答案,但您是否研究过App Engine上内置的Google存储API

我遵循这一点是为了将我的应用程序引擎python web服务与Google storage连接起来,特别是为了能够使用文件API。我看了buzz的例子,但似乎对我不起作用。我需要web服务在后台进行授权,以便能够从存储中检索我的文件

我试图使用decorator来传递我的客户id和客户机密,但这个过程对我来说并不十分清楚。谁能在这个过程中提供一个例子或详细说明一点


编辑:我正在使用Python2.7运行时。

这可能不是最直接的答案,但您是否研究过App Engine上内置的Google存储API


这让您可以绕过原生API。

这可能不是最直接的答案,但您是否研究过App Engine上内置的Google存储API


这使您可以一起绕过本机API。

如果您将apiclient与本机REST API一起使用,它看起来会像这样

from apiclient.discovery import build
import httplib2
from oauth2client.appengine import OAuth2Decorator

decorator = OAuth2Decorator(client_id=YOUR_GOOGLE_CLIENT_ID,
                            client_secret=YOUR_GOOGLE_CLIENT_SECRET,
                            scope=GOOGLE_SERVICE_SCOPE,
                            )

class MainHandler(webapp.RequestHandler):

   @decorator.oauth_required
   def get(self):
    service = build(SERVICE_NAME, 
                    SERVICE_VERSION,
                    http=decorator.http())
    magic = service.method()
查看其他API的一些ApicClient示例可能会有所帮助。例如,有一个应用程序引擎与Tasks API集成的好例子,它也使用OAuth2


如果您将apiclient与本机REST API一起使用,它看起来会像这样

from apiclient.discovery import build
import httplib2
from oauth2client.appengine import OAuth2Decorator

decorator = OAuth2Decorator(client_id=YOUR_GOOGLE_CLIENT_ID,
                            client_secret=YOUR_GOOGLE_CLIENT_SECRET,
                            scope=GOOGLE_SERVICE_SCOPE,
                            )

class MainHandler(webapp.RequestHandler):

   @decorator.oauth_required
   def get(self):
    service = build(SERVICE_NAME, 
                    SERVICE_VERSION,
                    http=decorator.http())
    magic = service.method()
查看其他API的一些ApicClient示例可能会有所帮助。例如,有一个应用程序引擎与Tasks API集成的好例子,它也使用OAuth2


我通过使用google appengine项目中的gslite.py脚本和我的凭据,成功地使其正常运行。

我通过使用google appengine项目中的gslite.py脚本和我的凭据,成功地使其正常运行。

是的,使用App Identity,您不需要执行OAuth。是的,使用App Identity,您不需要执行OAuth。但是您仍然可以从decorator检索访问令牌,并将其与REST API一起使用(请参阅decorator.credentials.access\u token和decorator.credentials.refresh\u token)。但是您仍然可以从decorator检索访问令牌,并将其与REST API一起使用(请参阅decorator.credentials.access_-token和decorator.credentials.refresh_-token)。“它似乎不起作用”没有帮助。您尝试了什么,发生了什么?