Atlassian Connect-Express:JIRA插件中的JIRA REST API身份验证

Sarthak srivastava

我正在使用atlassian-connect-express工具包通过Node.js创建基于Atlassian Connect的加载项。

它提供入站请求的自动JWT身份验证,以及将出站请求返回给主机的JWT签名。

当我将附件安装在JIRA仪表板中并返回以下有效负载时,该附件已通过身份验证:

{ key: 'my-add-on',
  clientKey: '*****',
  publicKey: '********'
  sharedSecret: '*****'
  serverVersion: '100082',
  pluginsVersion: '1.3.491',
  baseUrl: 'https://myaccount.atlassian.net',
  productType: 'jira',
  description: 'Atlassian JIRA at https://myaccount.atlassian.net ',
  eventType: 'installed' }

但是我无法使用框架生成的JWT令牌对JIRA Rest Api进行身份验证。它抛出以下错误消息。

404 '{"errorMessages":["Issue does not exist or you do not have permission to see it."],"errors":{}}'

以下是我发送GET请求时的代码:

 app.get('/getissue', addon.authenticate(), function(req, res){

 var request = require('request');
      request({
           url: 'https://myaccount.atlassian.net/rest/api/2/issue/ABC-1', 
           method: 'GET',   
    }, function(error, response, body){
        if(error){
            console.log("error!");
         }else{
            console.log(response.statusCode, body);
          }
    }); 
    res.render('getissue');
});

以下是我的应用程序描述符文件的代码:

{
"key": "my-add-on",
"name": "Ping Pong",
"description": "My very first add-on",
"vendor": {
    "name": "Ping Pong",
    "url": "https://www.example.com"
},
"baseUrl": "{{localBaseUrl}}",
"links": {
    "self": "{{localBaseUrl}}/atlassian-connect.json",
    "homepage": "{{localBaseUrl}}/atlassian-connect.json"
},
"authentication": {
    "type": "jwt"
},
"lifecycle": {
    "installed": "/installed"
},
"scopes": [
    "READ",
    "WRITE"
],
"modules": {
    "generalPages": [
        {
            "key": "hello-world-page-jira",
            "location": "system.top.navigation.bar",
            "name": {
                "value": "Hello World"
            },
            "url": "/hello-world",
            "conditions": [{
                "condition": "user_is_logged_in"
            }]
        },

            {
                "key": "getissue-jira",
                "location": "system.top.navigation.bar",
                "name": {
                    "value": "Get Issue"
                },
                "url": "/getissue",
                "conditions": [{
                    "condition": "user_is_logged_in"

                    }]                
        }
    ]
}

}

我很确定这不是我做的正确方法,要么我应该使用OAuth。但是我想让JWT身份验证方法在这里工作。

Sarthak srivastava

通过在此处签入JIRA ADD-On签名HTTP请求中的Atlassian Connect for Node.js Express Docs使其正常工作,如下所示。GET和POST。

得到:

app.get('/getissue', addon.authenticate(), function(req, res){
        var httpClient = addon.httpClient(req);
        httpClient.get('rest/api/2/issue/ABC-1',
        function(err, resp, body) {
                Response = JSON.parse(body);                              
                 if(err){
                    console.log(err);
                 }else {
                   console.log('Sucessful')
                   }
             });
            res.send(response);
         });

开机自检:

 var httpClient = addon.httpClient(req);
            var postdata = {
        "fields": {
           "project":
           { 
              "key": "MYW"
           },
           "summary": "My Story Name", 
            "description":"My Story Description", 
           "issuetype": {
              "name": "Story"
           }
          }
        }
        httpClient.post({
           url: '/rest/api/2/issue/' ,
           headers: {
                    'X-Atlassian-Token': 'nocheck'
                   },
           json: postdata

           },function (err, httpResponse, body) {
                if (err) {
                    return console.error('Error', err);
                      }
               console.log('Response',+httpResponse)

              });

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

JIRA REST API-基本身份验证

带有身份验证的requests.post为python中的jira rest api提供错误415

无法安装 Atlassian Connect Express

REST API中基于令牌的身份验证

使用 REST API 在 Go 中对 Azure 进行身份验证

Vue.js + REST API中的身份验证流程

使用openid-connect进行身份验证Spa和Rest API

无法使用WP REST API 2.0插件通过基本身份验证进行身份验证

REST API身份验证

Jira Rest Api基本身份验证令牌-PowerShell-使用安全字符串构建

如何在Rest API中验证/检查基本身份验证标头

带有(drf oidc)Django rest框架后端的Angular.js中基于OpenID Connect的身份验证

WordPress REST API-如何在没有插件的情况下进行身份验证

OpenID Connect-使用JWT通过REST API进行身份验证的Javascript应用程序的隐式流程

如何通过Mocha通过Passport Google OAuth身份验证测试Express REST API?

Gitlab Enterprise和Atlassian Jira集成-SSL证书验证错误

Docusign Connect API身份验证

rest api post方法不适用于meanjs 0.5.0中的基本身份验证

向JSON REST API进行身份验证时如何获取会话令牌(在R中)

React Native中的Firebase Rest API身份验证ID令牌和令牌刷新

了解使用Android和Rest API的OneDrive中的身份验证流程

空手道框架中REST API的NTLM身份验证

使用外部REST API在Symfony 3中进行自定义身份验证

对eXist-db中的REST API使用经过身份验证的会话/用户

通过react-admin中的REST API进行基于Cookie的身份验证

PHP中的System Center Operations Manager(SCOM)1801 REST API身份验证

Rails REST Api身份验证错误代码500(在Heroku中,但不在本地)

使用Node JS中的Keycloak访问令牌对Rest API进行身份验证

CAMUNDA API REST身份验证