0
我想要实现的是允许任何人登录到该网站,并且只有经过许可的某个注册用户才可以启动“点按此按钮...”我应该如何使用Google oAuth 2.0?
事情是,我非常不确定至于如何验证用户是否登录并具有合法令牌来访问该按钮。我应该在客户端的浏览器上存储令牌并在按下按钮时将其推送到服务器,这是否安全?
我应该在这种情况下使用PHP吗?
我的主页:
的Javascript & AJAX:
var token;
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
token = googleUser.getAuthResponse().id_token; // should I store the token?
var form = {
"ID": profile.getId(),
"Name": profile.getName(),
"Email": profile.getEmail(),
"Image_URL": profile.getImageUrl(),
}
$.ajax({
method: "POST",
url: "php/verification.php", // register account and save to db.
data: form,
dataType: "json",
success: function(data) {
console.log(data.result)
}
})
}
我也很模糊与文档: https://developers.google.com/identity/sign-in/web/backend-auth
会很开心如果有什么人ld启迪我的道路,并清除我的沮丧。