没有通过javascript响应google api调用
当一个用户登录时,我正试图获取Gmail联系人的电子邮件,以便在一个字段中自动完成他的朋友列表 在阅读了很多并尝试了一些示例代码之后,我无法得到以下响应:没有通过javascript响应google api调用,javascript,google-api,google-authentication,Javascript,Google Api,Google Authentication,当一个用户登录时,我正试图获取Gmail联系人的电子邮件,以便在一个字段中自动完成他的朋友列表 在阅读了很多并尝试了一些示例代码之后,我无法得到以下响应: var id_token = googleUser.getAuthResponse().id_token; 以下是联系电话: <div class="g-signin2" data-onsuccess="onSignIn"></div> <script type="text/javascript">
var id_token = googleUser.getAuthResponse().id_token;
以下是联系电话:
<div class="g-signin2" data-onsuccess="onSignIn"></div>
<script type="text/javascript">
function onSignIn(googleUser) {
var profile = googleUser.getBasicProfile();
//alert('bingo');
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());
var id_token = googleUser.getAuthResponse().id_token;
console.log("ID Token: " + id_token);
var url = "https://www.google.com/m8/feeds/contacts/default/full?access_token=" + id_token + + "&alt=json";
$.ajax({
url: url,
type: "GET",
dataType: 'jsonp',
cache: false,
success: function (response) {
alert(response);
},
error: function (status) {
alert(status);
}
});
};
</script>
我从未看到alertresponse或alertstatus
谢谢。浏览器调试工具(如Chrome Dev tools)的“网络”选项卡中发生了什么事?只是一个没有响应的get。。。