本文档介绍如何使用 Identity Platform 让用户通过 Google 登录。 本教程假定您已启用 Identity Platform,并且拥有一个使用 HTML 和 JavaScript 编写的基本 Web 应用。如需了解具体方法,请参阅快速入门。 如需将 Google 配置为身份提供商,请执行以下操作: 转到 Google Cloud 控制台中的身份提供商页面。 转到“身份提供商”页面 点击添加提供商。 从列表中选择 Google。 输入您的 Google Web 客户端 ID 和 Web 密钥。如果您还没有 ID 和密钥,则可以从 API 和服务页面获取一个。 将配置 Google 下列出的 URI 配置为您的 Google 应用的有效 OAuth 重定向 URI。 点击已获授权的网域下的添加网域,以注册您应用的网域。出于开发目的, 在配置您的应用下,点击设置详情。将代码段复制到应用的代码中,以初始化 Identity Platform Client SDK。 点击保存。 让用户通过 Client SDK 登录
获得访问令牌后,您就可以使用它来调用 Google API。例如: RESTcurl -H "Authorization: Bearer [TOKEN]" https://www.googleapis.com/oauth2/v2/userinfo 手动让用户登录如果您不想使用 Client SDK,也可以手动处理登录流程:
后续步骤
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates. Last updated 2022-10-27 UTC. [{ "type": "thumb-down", "id": "hardToUnderstand", "label":"很难理解" },{ "type": "thumb-down", "id": "incorrectInformationOrSampleCode", "label":"信息或示例代码不正确" },{ "type": "thumb-down", "id": "missingTheInformationSamplesINeed", "label":"没有我需要的信息/示例" },{ "type": "thumb-down", "id": "translationIssue", "label":"翻译问题" },{ "type": "thumb-down", "id": "otherDown", "label":"其他" }] [{ "type": "thumb-up", "id": "easyToUnderstand", "label":"易于理解" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"解决了我的问题" },{ "type": "thumb-up", "id": "otherUp", "label":"其他" }] |