【发布时间】:2015-03-23 08:32:07
【问题描述】:
我正在使用 Google Cloud Endpoints 制作一个 REST API。
我的 API 提供事件服务,例如 Google Calendar Event。
但我的事件模型具有与 Google 日历不同的其他属性。
所以我想将其他属性存储到我的数据存储中。
和其他人存储谷歌日历 API。
顺便说一句,我不知道如何使用 Google API Python 客户端进行 OAuth2 身份验证。
decorator = OAuth2Decorator(
client_id='',
client_secret='',
scope='https://www.googleapis.com/auth/calendar')
service = build('calendar', 'v3')
@space_api.api_class(resource_name='events')
class EventsApi(remote.Service):
@endpoints.method(EVENT_RESOURCE, EventMessage,
path='events', http_method='POST',
name='events.insert')
@decorator.oauth_required
def events_insert(self, request):
event = service.events().insert(calendarId='primary', body=encode_message(request)).execute(http=decorator.http())
return decode_message(EventMessage, event)
我使用 OAuth2Decorator 但 remote.Service 类没有重定向方法。
所以它会导致错误。
如何在 Google Cloud Endpoints 中使用 Google API Python 客户端。
请告诉我如何验证 OAuth2。
欢迎任何评论,例如文档链接。
【问题讨论】:
标签: python google-app-engine google-cloud-endpoints google-api-python-client