我已经实现了生成的 HTML (https://developers.google.com/identity/gsi/web/tools/configurator?hl=de) 代码来启用 Google 登录我的 Web 应用程序(在 django 中),但是当我加载网站时,谷歌按钮不会出现。这是我的 HTML 代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer-when-downgrade">
<script src="https://accounts.google.com/gsi/client" async ></script>
<title>Login</title>
</head>
<body>
<p>Login with Google</p>
<div id="g_id_onload"
data-client_id="CLIENT-ID"
data-context="signin"
data-ux_mode="redirect"
data-login_uri="http://127.0.0.1:8000/googleauth/"
data-itp_support="true">
</div>
<div class="g_id_signin"
data-type="standard"
data-shape="rectangular"
data-theme="outline"
data-text="signin_with"
data-size="large"
data-logo_alignment="left">
</div>
</body>
</html>
没有错误消息,所以我不知道如何解决问题,特别是因为我不是经验丰富的开发人员。
你的代码看起来不错。我只是想确保您已创建 Google API 客户端 ID 并替换
data-client_id="CLIENT-ID"
中的客户端 ID?
由于您使用的是
data-login_uri
和 redirect
,您还需要正确配置授权重定向 URI(请参阅步骤 5)
谢谢, 赫尔曼