Atlassian Jira-仅在使用查询参数时为401 [英] Atlassian Jira - 401 only when using query parameters

查看:311
本文介绍了Atlassian Jira-仅在使用查询参数时为401的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前正在使用ACE框架开发JIRA插件.使用集成的httpClient执行请求.

Currently working on a JIRA addon using the ACE framework. Executing a request using the integrated httpClient.

当我发出这样的请求

https://instance.atlassian.net/rest/api/3/search

使用标头Authorization: JWT <token>可以正常工作,但是当我使用类似这样的查询参数运行相同的请求

it works fine using the header Authorization: JWT <token> but when I run the same request with a query parameter like this

https://instance.atlassian.net/rest/api/3/search?maxResults=1

请求失败,并显示401.我已确认JWT未到期,原因是还原了查询参数并再次看到成功.

the request fails with a 401. I have confirmed that the JWT is not expired due to reverting the query parameters and seeing success again.

我的atlassian-connect.json具有端点要求的范围READ.

My atlassian-connect.json has scope READ as requested by the endpoint.

有什么建议吗?

推荐答案

由于您正在使用ACE并利用了httpClient,因此您可能想尝试使用checkValidToken()路由.下面的代码段对我有用.

Since you're using ACE and utilizing httpClient, you might want to try the checkValidToken() route instead. The snippet below worked for me.

app.get('/mySearch', addon.checkValidToken(), function(req, res) {
    var httpClient = addon.httpClient(req);

    httpClient.get({
        url: '/rest/api/3/search?maxResults=1',
        headers: {
            'X-Atlassian-Token': 'nocheck',
            'Content-Type': 'application/json'
        }
    },
    function (err, httpResponse, body) {
        if (err) {
            return console.error('Search failed:', err);
        }

        console.log('Search successful:', body);
    });
});

这篇关于Atlassian Jira-仅在使用查询参数时为401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆