Javascript 如何使用google one tap signin获取个人资料和用户信息
我正在尝试使用google one tap登录获取配置文件信息,我获取的是clientId和凭据,而不是用户配置文件,我也使用了其他gapi方法,但我无法获取,有人能建议如何提取吗Javascript 如何使用google one tap signin获取个人资料和用户信息,javascript,oauth-2.0,google-oauth,google-one-tap,Javascript,Oauth 2.0,Google Oauth,Google One Tap,我正在尝试使用google one tap登录获取配置文件信息,我获取的是clientId和凭据,而不是用户配置文件,我也使用了其他gapi方法,但我无法获取,有人能建议如何提取吗 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" conte
<!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>
文件
函数handleCredentialResponse(响应){
控制台日志(响应);
auth2=gapi.auth2.init({
客户id:“xxxxxx”,
范围:
“电子邮件档案https://www.googleapis.com/auth/plus.business.manage",
提示:“无”,
});
auth2.signIn().then(函数(){
console.log(auth2.currentUser);
});
作者2
Grantoflineaccess({
范围:
“电子邮件档案https://www.googleapis.com/auth/plus.business.manage",
})
.then(异步函数(resp){
var auth_code=对应代码;
//这是授权码
});
}