简体   繁体   English

Jira REST API服务器到服务器身份验证

[英]Jira REST API server-to-server authentication

I didn't find any question that describes how to do server-to-server authentication with Jira API so I'm posting this QA-style. 我没有找到任何描述如何使用Jira API进行服务器到服务器身份验证的问题,因此我发布了这种QA风格。 This solution assumes jira cloud but probably translates to other setups as well. 此解决方案假设jira cloud,但也可能转换为其他设置。

If you are building a webapp and want users to authenticate as themselves, you should look at OAuth as discussed here: Access JIRA API with api key without username and password 如果您正在构建一个webapp并希望用户自己进行身份验证,那么您应该查看OAuth,如下所述: 使用api密钥访问JIRA API,无需用户名和密码

But if you want a "service-account"/"bot" account on your server to interact with Jira API as "itself", here is how... 但是,如果您希望服务器上的“服务帐户”/“僵尸”帐户与Jira API作为“本身”进行交互,那么以下是...

Reference: https://confluence.atlassian.com/cloud/api-tokens-938839638.html 参考: https//confluence.atlassian.com/cloud/api-tokens-938839638.html

First you (or site admin) needs to create the bot account. 首先,您(或站点管理员)需要创建机器人帐户。 Then log in to the account and create an API token from here (assumes Jira cloud): https://id.atlassian.com/manage/api-tokens?_ga=2.69222547.2064924674.1559628016-830461555.1535725383 然后登录该帐户并从此处创建API令牌(假设Jira云): https ://id.atlassian.com/manage/api-tokens?__ www = 2.69222547.2064924674.1559628016-830461555.1535725383

Then you can use [user-email]:[auth-token] as user/password for basic auth. 然后您可以使用[user-email]:[auth-token]作为基本身份验证的用户/密码。 Examples: 例子:

Curl 卷曲

curl -u bot@company.com:AAABBBCCC https://[company].atlassian.net/rest/api/latest/issue/DEV-123

NodeJS got: NodeJS得到:

const issueContent = await gotService.get(
  'https://[company].atlassian.net/rest/api/latest/issue/DEV-123',
  {
    auth: 'bot@company.com:AAABBBCCC'
  }
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM