【发布时间】:2015-01-27 04:53:49
【问题描述】:
我正在使用 Python 中的 Google Cloud 后端项目来支持 Android 应用程序。我希望服务器能够对用户的帐户进行一些 API 调用 (如联系人、地图等)而不是让 Android 客户端承担此开销。 我根本没有使用 Webapp。我宁愿不这样做 - 我看不出它本身的需要,除非这是完成这项工作的唯一方法。
想知道我将如何前进:
@endpoints.api(name='data_api',
version='v1',
description='Access, create or delete data for meetups.',
audiences=client_ids.allowed_client_ids,
scopes=[ # Get email and Details
endpoints.EMAIL_SCOPE,
# Get Contacts
client_ids.CONTACTS_SCOPE
])
class DataApi(remote.Service):
@UserModel.method(name='user.fetch',
user_required=True)
def get_all_contacts(self, query):
#Now what?
我想需要将 Auth 令牌中继到从服务器到 Google API 的另一个自定义请求上,但我不知道如何提取它并将其向前推进。在文档中找不到它或在此处有任何问题。
感谢您的帮助。
编辑: 我确实知道如何检查用户是否经过身份验证,但这并没有告诉我如何使用相同的身份验证令牌访问 Google API。
if endpoints.get_current_user() is not None:
#Do secret authenticated business...
【问题讨论】:
标签: python google-app-engine google-maps-api-3 google-cloud-endpoints google-contacts-api