我有以下代码通过 Google+ 登录按钮对用户进行身份验证:
<html>
<head>
<!-- google api -->
<meta name="google-signin-client_id" content="xxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com">
<meta name="google-signin-scope" content="email">
</head>
<body>
<div id="google-signin"></div>
<script>
function signOut() {
var auth2 = gapi.auth2.getAuthInstance();
auth2.signOut().then(function () {
console.log('User signed out.');
});
function onGoogleSuccess(googleUser) {
// get the token
var id_token = googleUser.getAuthResponse().id_token;
// console.log('Logged in as: ' + googleUser.getBasicProfile().getName());
}
function onGoogleFailure(error) {
console.log(error);
}
function renderButton() {
gapi.signin2.render('google-signin', {
'scope': 'https://www.googleapis.com/auth/plus.login',
'width': 242,
'height': 56,
'longtitle': true,
'theme': 'dark',
'onsuccess': onGoogleSuccess,
'onfailure': onGoogleFailure
});
}
</script>
</body>
</html>
当我单击该按钮时,会出现一个身份验证弹出窗口,一旦我对其进行授权,“onGooglesuccess”功能就会运行,但它不会重定向到页面。我希望它重定向到一个特定的 .aspx 页面,我可以在其中获取代码,用 tokrn 替换它并获取用户信息。
我怎样才能做到这一点?我尝试阅读 Google 上的文档,但我不知道该怎么做。
我正在用 ASP.NET 4.5 / C# / Javascipt 开发我的应用程序