2016-05-12 160 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 「 –