2016-04-27 134 views
0

我想讓用戶在成功使用google api登錄後在JIRA中登錄。 我得到access_token代碼在我的servlet類中,但無法登錄到jira。成功使用google api登錄後的Jira登錄

我得到了一些解決方案,但大多數方法已被棄用。

在此先感謝。 :)

+0

你能分享到目前爲止你已經嘗試過的代碼? – Sam

回答

0

@SAM

這裏是代碼...

的.js用ajax,我打電話servlet和發送數據

callingServlet(responseEmail,responseAccess_token,responseCode){ 
    AJS.$.ajax({ 
      url: "/plugins/servlet/google/login", 
      type: "POST", 
      data: ({ email:responseEmail, access_token:responseAccess_token, code:responseCode}), 
      dataType: "json", 
     }); 
} 

Atlassian的-plugin.xml我已配置servlet

<servlet name="google-login-servlet" key="googleloginservlet" class="in.componence.jira.plugin.google.GoogleLoginServlet"> 
     <url-pattern>/google/login</url-pattern> 
    </servlet> 

,並在裏面的doPost我的Servlet類()

Collection<ApplicationUser> jiraUsersCollection= ComponentAccessor.getUserUtil().getUsers(); 


     for (Iterator iterator = jiraUsersCollection.iterator(); iterator.hasNext();) { 

      ApplicationUser jiraCrowdUser = (ApplicationUser) iterator.next(); 
      if(jiraCrowdUser.getEmailAddress().equalsIgnoreCase(googleEmail)){ 
       System.out.println("User Found with : "+jiraCrowdUser.getUsername()+" and Email: "+jiraCrowdUser.getEmailAddress()); 
       Principal userToLogin = (Principal)jiraCrowdUser; 





       response.sendRedirect("/secure/Dashboard.jspa"); 
       return; 
      } 
     }