Javascript 如何实现Google+;登录C#>;网
我遵循谷歌在其网站上提供的程序,就像我的HTML代码一样Javascript 如何实现Google+;登录C#>;网,javascript,c#,google-api-js-client,Javascript,C#,Google Api Js Client,我遵循谷歌在其网站上提供的程序,就像我的HTML代码一样 <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width" /> <meta name="google-signin-client_id" content="xasdas.apps.googleusercontent.com">
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<meta name="google-signin-client_id" content="xasdas.apps.googleusercontent.com">
<script src="~/Scripts/jquery.js"></script>
<script src="https://apis.google.com/js/platform.js" async defer></script></head>
....
<body>
<div class="g-signin2" data-onsuccess="onSignIn" style="float:left;margin-left:30px;"></div>
</body>
我的意思是我是说我是如何得到名字和电子邮件id的,但突然它停止了工作。该按钮正在转换为登录,但我没有收到任何警报
我只需要这个api的名称和电子邮件,rest登录部分由其他部分负责,但我甚至无法获得这两个部分。
我需要的是:
如果用户已登录,我需要显示姓名和电子邮件。
如果他没有登录,请显示对话框登录g+,然后显示他的姓名和电子邮件。我发现这也非常复杂。有数千篇文章,每一篇都几乎不同于另一篇。我仍在寻找如何正确地处理它。我发现它也很复杂。有数千篇文章,每一篇都几乎不同于另一篇。我仍在寻找如何把它做好。
function onSignIn(googleUser) {
Useful data for your client-side scripts:
alert("Rached Here");
var profile = googleUser.getBasicProfile();
alert("ID: " + profile.getId()); // Don't send this directly to your server!
console.log("Name: " + profile.getName());
console.log("Image URL: " + profile.getImageUrl());
console.log("Email: " + profile.getEmail());
};
gapi.load('auth2', function () {
alert("Reached Here1");
auth2 = gapi.auth2.init({
client_id: '...apps.googleusercontent.com',
});
// Sign the user in, and then retrieve their ID.
auth2.signIn().then(function () {
var profile = auth2.currentUser.get().getBasicProfile();
alert("Reached Here");
//facebook_authentication(profile.getName(), profile.getEmail());
});
});