使用放大进行谷歌身份验证时缺少必需的参数client_id

问题描述

我正在尝试在 AWS 上使用 Amplify 设置 Google 登录

运行 CLI 工具后,创建了一个 aws-exports.js 文件。 该文件内容如下所示。 (出于安全原因,我模糊了一些 ID)

aws-exports.js

我在组件的 html 中添加一个按钮:

<amplify-google-button></amplify-google-button>

确实显示了 google 的登录按钮。

Google sign in button

但是,当我单击按钮时,控制台日志中会显示错误

Dw {message: "Missing required parameter 'client_id'",KK: true,stack: "gapi.auth2.ExternallyVisibleError: Missing require…ask (http://localhost:4200/polyfills.js:10872:18)"}
KK: true
message: "Missing required parameter 'client_id'"
stack: "gapi.auth2.ExternallyVisibleError: Missing required parameter 'client_id'↵    at new Dw (https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.nl.r1otz6eix_k.O/m=client/rt=j/sv=1/d=1/ed=1/am=wQE/rs=AGLTcCOGfNNm-txjpYHjoYjEhq8W5zaIHw/cb=gapi.loaded_0:555:25)↵    at ox (https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.nl.r1otz6eix_k.O/m=client/rt=j/sv=1/d=1/ed=1/am=wQE/rs=AGLTcCOGfNNm-txjpYHjoYjEhq8W5zaIHw/cb=gapi.loaded_0:574:131)↵    at Object._.Lx [as init] (https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.nl.r1otz6eix_k.O/m=client/rt=j/sv=1/d=1/ed=1/am=wQE/rs=AGLTcCOGfNNm-txjpYHjoYjEhq8W5zaIHw/cb=gapi.loaded_0:592:269)↵    at AmplifyGoogleButton.getAuthInstance (http://localhost:4200/13.js:278:38)↵    at AmplifyGoogleButton.signInWithGoogle (http://localhost:4200/13.js:288:14)↵    at HTMLElement.onClick (http://localhost:4200/13.js:294:129)↵    at ZoneDelegate.invokeTask (http://localhost:4200/polyfills.js:9650:35)↵    at Zone.runTask (http://localhost:4200/polyfills.js:9418:51)↵    at ZoneTask.invokeTask [as invoke] (http://localhost:4200/polyfills.js:9731:38)↵    at invokeTask (http://localhost:4200/polyfills.js:10872:18)"
__proto__: _.Tc

在创建所有这些之前,我在 Google Cloud Platform 上创建了一个客户端 ID。

Google Cloud Platform ID

Amplify 配置页面一个名为“ZBaduk”的应用程序,其环境名为“dev”。此页面链接到身份验证中的 cognito:

Amplify linked to Cognito

此 ID 与 AWS 用户池的 ID 有效匹配,该 ID 具有 Google 身份的配置。

User Pool ID

那么,还有其他地方需要我输入谷歌客户端 ID 吗?

解决方法

amplify-google-button 元素上应该有一个 client-id 属性。

<amplify-google-button clientId="87153937946-md7....apps.googleusercontent.com"></amplify-google-button>

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...