如何解决如何使用Google一键式登录获取个人资料和用户信息
我正在尝试使用Google一键式登录获取个人资料信息,并且我正在获取clientId和凭据而不是用户个人资料,并且我也使用了其他gapi方法,但是我无法获得,有人可以建议如何提取
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<title>Document</title>
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="https://accounts.google.com/gsi/client" async defer></script>
<script src="https://apis.google.com/js/client.js?onload=authorize"></script>
<script src="https://www.gstatic.com/firebasejs/5.0.3/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/5.0.3/firebase-firestore.js"></script>
</head>
<body>
<div
id="g_id_onload"
data-client_id="xxxxxx"
data-callback="handleCredentialResponse"
></div>
<script>
function handleCredentialResponse(response) {
console.log(response);
auth2 = gapi.auth2.init({
client_id: "xxxxxx",scope:
"email profile https://www.googleapis.com/auth/plus.business.manage",prompt: "none",});
auth2.signIn().then(function () {
console.log(auth2.currentUser);
});
auth2
.grantOfflineAccess({
scope:
"email profile https://www.googleapis.com/auth/plus.business.manage",})
.then(async function (resp) {
var auth_code = resp.code;
// here i am getting the authorization code
});
}
</script>
</body>
</html>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。