Access JIRA API with api key without username and password

♀尐吖头ヾ 提交于 2019-12-02 02:15:16

Yes, JIRA supports OAuth for that purpose, see: https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+OAuth+authentication

Unfortunately there's no C# sample code provided, but you should be able to assemble a solution from the other programming languages here: https://bitbucket.org/atlassian_tutorial/atlassian-oauth-examples/src

You should use a generic OAuth library anyhow.

Oauth is great for when you need the actual user to log in and you are in the context of a browser.

However, for server-to-server communication that is not linked to any specific user (e.g. CI) you may want to create a "bot" account on your jira server and authenticate with API tokens. Creation of tokens is described here: https://confluence.atlassian.com/cloud/api-tokens-938839638.html

Then you can use [user-email]:[auth-token] as user/password to basic auth. Examples:

Curl

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

NodeJS got:

const issueContent = await gotService.get(
  'https://[company].atlassian.net/rest/api/latest/issue/DEV-123',
  {
    auth: 'bot@company.com:AAABBBCCC'
  }
)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!