<body>
<script src="https://accounts.google.com/gsi/client" async defer></script>
<div id="g_id_onload"
data-client_id="790854323959-v2lniefhl7ripoijm0ooetu9ari91g3q.apps.googleusercontent.com"
data-callback="handleCredentialResponse">
</div>
<div class="g_id_signin" data-type="standard"></div>
<script>
function handleCredentialResponse(response) {
// decodeJwtResponse() is a custom function defined by you
// to decode the credential response.
const responsePayload = decodeJwtResponse(response.credential);
console.log("ID: " + responsePayload.sub);
console.log('Full Name: ' + responsePayload.name);
console.log('Given Name: ' + responsePayload.given_name);
console.log('Family Name: ' + responsePayload.family_name);
console.log("Image URL: " + responsePayload.picture);
console.log("Email: " + responsePayload.email);
}
</script>
</body>
注意:我想使用javascript将google登录整合到php项目中。但是我收到了错误信息,比如- decodeJwtResponse没有在Nn.handleCredentialResponse [作为回调]中定义。请帮助我,我想获得个人资料的详细信息。请提供我所有关于我查询的详细信息。
2条答案
按热度按时间vxf3dgd41#
答案就在你从谷歌复制的代码里。
您需要自己定义函数来解码CredentialResponse。
2hh7jdfx2#
这将与有效响应一起工作