我已经在使用 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"
});
}
希望任何人都可以提供帮助