[英]How do I add Google Account authentication to Google Cloud Endpoints in Python
I'm trying to make a Google Cloud Endpoints backend for my Android app that uses a user's Google Account for authentication. 我正在尝试为我的Android应用制作一个Google Cloud Endpoints后端,该后端使用用户的Google帐户进行身份验证。 I've found that the Java API contains annotations for OAuth scopes, but the python documentation only makes a single reference to that.
我发现Java API包含OAuth范围的注释,但是python文档仅对此做了一个引用。
Here is the annotation I'm using on the endpoint: 这是我在端点上使用的注释:
@endpoints.api(name='notes', version='v1',
description='Notes API',
allowed_client_ids=[CLIENT_ID, endpoints.API_EXPLORER_CLIENT_ID],
audiences=[AUDIENCE],
scopes=['https://www.googleapis.com/auth/userinfo.email'])
But the generated code doesn't have any scopes: 但是生成的代码没有任何范围:
/**
* Available OAuth 2.0 scopes for use with the .
*
* @since 1.4
*/
public class NotesScopes {
private NotesScopes() {
}
}
Even the generated service class seems to be missing pieces: 甚至生成的服务类似乎也缺少:
/**
* The default encoded root URL of the service. This is determined when the library is generated
* and normally should not be changed.
*
* @since 1.7
*/
public static final String DEFAULT_ROOT_URL = "https://None/_ah/api/";
/**
* The default encoded service path of the service. This is determined when the library is
* generated and normally should not be changed.
*
* @since 1.7
*/
public static final String DEFAULT_SERVICE_PATH = "notes/v1/";
I'm assuming that I'm missing some annotation or config option. 我假设我缺少一些注释或配置选项。 Does anyone know what it might be?
有谁知道这可能是什么?
The scopes
attribute in the annotation isn't used in the Android auth flow, which is one of the reasons it's not included in the generated Java code. 批注中的
scopes
属性未在Android身份验证流程中使用,这是未包含在生成的Java代码中的原因之一。 Instead, Android uses an ID token, which contains sufficient information to represent your user/application to the backend, without requesting a scope. 相反,Android使用ID令牌,该令牌包含足够的信息来向后端表示您的用户/应用程序,而无需请求范围。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.