0

我已经在使用 jquery 的网站中使用 google 实现了登录。前几天它运行良好,但从今天开始它会导致问题并给出错误。

网站链接是http://dev.ganitgurooz.com/

错误是:未捕获的类型错误:无法调用未定义的方法授权

我的 jquery 代码是: gmlogin:function(){ var accessToken; var config = { 'client_id': 'MY-Client-Id', 'scope': ' https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo。电子邮件', };

home.auth(config);          
},
auth:function(config) {
gapi.auth.authorize(config, function() {
accessToken = gapi.auth.getToken().access_token;
console.log(accessToken);
home.validateToken();       
});
},
validateToken:function() {
$.ajax({
url: 'https://www.googleapis.com/oauth2/v1/tokeninfo?access_token='+accessToken,
data: null,
success: function(response){  
home.getUserInfo();
},  
error: function(error) {
},
dataType: "jsonp" 
});
},
getUserInfo:function() {
$.ajax({
url: 'https://www.googleapis.com/oauth2/v1/userinfo?access_token='+accessToken,
data: null,
success: function(response) {
console.log(response);
var gmail ='gmail';
var dataString         ='gmail='+gmail+'&fname='+response.given_name+'&lname='+response.family_name+'&email='+response.email+'&gmId='+response.id+'&dob='+response.birthday;



$.post(common.getSiteURL() +'/Remote/validateUsers',dataString,function(data){
console.log(data);
var redirect_url = '/';
if (data == "SUCCESS") {                                                   

if(getCookie("redirect_url")){


redirect_url = getCookie("redirect_url");
}


window.location.href = redirect_url ;
}else{


window.location.href='/';
}
});

},
dataType: "jsonp"
});
}

希望任何人都可以提供帮助

4

1 回答 1

-1

得到问题谷歌授权的解决方案我找到了它的新方法。

Google 身份验证和授权 Javascript 弹出窗口中 Google API 的身份验证和授权 - 教程

我在这里发布我的答案是因为它还有其他人。

我没有在 localhost 上得到正确的响应,但是当我将代码上线时它可以正常工作。谢谢

于 2014-01-31T13:08:28.933 回答