我正在使用Google API
登录用户。他们可以登录,但是我需要从客户端将信息发送到服务器端代码
我不确定如何解决这个问题,我看过sending data from client side to server side,但找不到解决方法
这是我的HTML
<!-- sign in button -->
<div id="signin" class="g-signin2" data-onsuccess="onSignIn"></div>
<!-- The client sided function -->
<script>
function onSignIn(googleUser) {
// get user profile information
console.log(googleUser.getBasicProfile())
var profile = googleUser.getBasicProfile();
console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
console.log('Name: ' + profile.getName());
console.log('Image URL: ' + profile.getImageUrl());
console.log('Email: ' + profile.getEmail()); // This is null if the 'email' scope is not present.
document.getElementById("signin").style.display = "none"
document.getElementById("signout").style.display = "block"
}
</script>
有没有一种方法可以将googleUser.getBasicProfile()
发送到服务器端代码,或者仅将onSignIn()
函数发送到服务器端并运行它