为什么 Django 中的 Google-Auth(Google Identity) 弹出窗口空白?
我的 Google 身份验证卡在弹出身份验证流程中。一键式身份验证工作正常,但按钮 不行。我点击它,弹出窗口打开,但它仍然空白,没有任何进展。
<script>
function handleCredentialResponse(response) {
console.log("Encoded JWT ID token: " + response.credential);
...
}
window.onload = function () {
google.accounts.id.initialize({
client_id: "531144-------",
callback: handleCredentialResponse
});
google.accounts.id.renderButton(
document.getElementById("g_id_signin"),
{ theme: "outline", size: "large" } // customization attributes
);
google.accounts.id.prompt(); // also display the One Tap dialog
}
</script>
<div id="g_id_signin"></div>
我拥有所有域,在授权重定向 URI 和重定向中添加了 localhost。但我仍然无法让弹出窗口填充并完成身份验证流程。 任何帮助表示赞赏。
此时我在 FIREFOX 中遇到的错误:
未捕获类型错误:window.opener 为 null li https://ssl.gstatic.com/_/gsi/_/js/k=gsi.gsi.en.i....O/am=wg/d=1/rs=AF0... w/m=credential_page_library:291 mi https://ssl.gstatic.com/_/gsi/_/js/k=gsi.gsi.en.i.....O/am=wg/d=1/rs=AF0.. .w/m=credential_page_library:29
在 CHROME 中:
未捕获的类型错误:无法读取 null 的属性(正在读取 '发布消息') 在李 (m=credential_page_library:291:151)
My Google Auth is Stuck in the popup auth flow. The one-tap authentication works just fine but not the button<div id="g_id_signin"></div>
. I click on it, the popup opens but it remains there blank with no progress.
<script>
function handleCredentialResponse(response) {
console.log("Encoded JWT ID token: " + response.credential);
...
}
window.onload = function () {
google.accounts.id.initialize({
client_id: "531144-------",
callback: handleCredentialResponse
});
google.accounts.id.renderButton(
document.getElementById("g_id_signin"),
{ theme: "outline", size: "large" } // customization attributes
);
google.accounts.id.prompt(); // also display the One Tap dialog
}
</script>
<div id="g_id_signin"></div>
I have all the domains, localhost added in Authorized redirect URIs and Redirects. But I still can't get the popup to populate and complete the authentication flow.
Any help is appreciated.
At this point the error I am getting in FIREFOX:
Uncaught TypeError: window.opener is null
li https://ssl.gstatic.com/_/gsi/_/js/k=gsi.gsi.en.i....O/am=wg/d=1/rs=AF0...w/m=credential_page_library:291
mi https://ssl.gstatic.com/_/gsi/_/js/k=gsi.gsi.en.i.....O/am=wg/d=1/rs=AF0...w/m=credential_page_library:29
And in CHROME:
Uncaught TypeError: Cannot read properties of null (reading
'postMessage')
at li (m=credential_page_library:291:151)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须在settings.py中将
SECURE_CROSS_ORIGIN_OPENER_POLICY
设置为“same-origin-allow-popups”
。参考:https://github.com/google/google -api-javascript-client/issues/796#issuecomment-1118136612
You have to set
SECURE_CROSS_ORIGIN_OPENER_POLICY
to"same-origin-allow-popups"
in settings.py.Reference: https://github.com/google/google-api-javascript-client/issues/796#issuecomment-1118136612