[英]How can I use the OAuth2Decorator with Google Cloud Storage?
我正在按照此說明進行操作 ,以便將我的應用程序引擎python網絡服務與Google存儲設備連接起來,尤其是能夠使用文件API。 我經歷了一個嗡嗡聲的例子,但似乎不適用於我。 我需要Web服務在后台進行授權,以便能夠從存儲中檢索我的文件。
我正在嘗試使用裝飾器來傳遞我的client_id和client_secret,但是這個過程對我來說並不十分清楚。 誰能在此過程中提供示例或詳細說明?
編輯:我正在使用python 2.7運行時。
這可能不是最直接的答案,但是您是否探索了App Engine上內置的Google Storage API?
http://code.google.com/appengine/docs/python/googlestorage/
這使您可以一起繞過本機API。
我設法得到它通過使用腳本gslite.py從正常運行AU-待辦事項與我的憑據谷歌的AppEngine項目。
如果您將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的一些apiclient示例可能會有所幫助。 例如,有一個很好的例子,說明App Engine與Tasks API的集成也使用了OAuth2。
http://code.google.com/appengine/articles/python/getting_started_with_tasks_api.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.