简体   繁体   English

如何在Python中将Google帐户身份验证添加到Google Cloud Endpoints

[英]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.

相关问题 如何向Google Cloud端点添加身份验证? - How to add authentication to google cloud endpoints? Google Cloud Endpoints OAuth身份验证 - Google Cloud Endpoints OAuth Authentication Google Cloud Endpoints自定义身份验证 - Google Cloud Endpoints custom Authentication 如何将Facebook登录和电子邮件注册添加到我的Google Cloud Endpoints App(Java)? - How do I add both Facebook Login and Email registration to my Google Cloud Endpoints App (Java)? 如何使用Firebase Auth(非Google帐户)使Google Cloud Endpoints能够用于经过身份验证的呼叫? - How can I get Google Cloud Endpoints to work for authenticated calls with Firebase Auth (non-Google Account)? 如何在没有用户Google登录的情况下在Android上调用Google Cloud Endpoints? - How do I call Google Cloud Endpoints on Android without user Google sign-in? Google Cloud Endpoints和用户身份验证 - Google Cloud Endpoints and user's authentication Android客户端-使用Google Cloud Endpoints的Google App引擎身份验证 - Android Client - Google App engine authentication using Google Cloud Endpoints 在没有Google帐户登录的情况下将您的客户端验证到Cloud Endpoints - Authenticating your client to Cloud Endpoints without a Google Account login Google Cloud Endpoints工作流程 - Google Cloud Endpoints workflow
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM