2016-05-12 161 views
0

我已经创建了一个插件,通过我对/login.jsp/secure/Dashboard.jspa的登录小工具的谷歌登录按钮。JIRA登录与谷歌认证

一切工作好上/login.jsp但谷歌API不装上/dashboard.jspa。 在我的.js: -

AJS.$(function() { 
    var po = document.createElement("script"); 
    po.type = "text/javascript"; 
    po.async = true; 
    po.src = "https://apis.google.com/js/client:platform.js"; 
    var s = document.getElementsByTagName("script")[0]; 
    s.parentNode.insertBefore(po, s); 
}); 

gapi.auth.signIn({ 
     callback: gPSignInCallback, 
     clientid: CLIENT_ID, 
     cookiepolicy: "single_host_origin", 
     approvalprompt: "force", 
     requestvisibleactions: "http://schema.org/AddAction", 
     scope: "https://www.googleapis.com/auth/plus.login email" 
    }) 

/dashboard.jspagapi.auth是取消定义是在控制台上抛出。

回答

1

您需要先定义'auth'对象,然后用gapi.auth2.init()调用来初始化它。

这里是定义auth2对象的例子:

var auth2=""; 
var onGoogleLoad = function() { 
    gapi.load('auth2', function() { 
     auth2 = gapi.auth2.init({ 
     client_id: 'YOUR CLIENT ID', 
    }) 
    enableGoogleButton() 
    }) 
} 
+0

谢谢@Deepak,得到了一些解决方案,但仍得到一个错误“RPC:请求被拒绝(坏原点):https://accounts.google.com “ –