how to create Basic authentication for JIRA REST API in node JS

Natnael Tamrat June 30, 2021

help me in creating authentication for JIRA REST API in node js with just username and password of jira atlassian account .

1 answer

0 votes
Dario B
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 1, 2021

Hello @Natnael Tamrat ,

Welcome to the Atlassian Community!

Please notice that basic authentication with username and password has been deprecated long time ago in Cloud and that you now have to use Atlassian account email address and API token instead:

 

For the rest, all you have to do is to add an authorization header to your call built by following the instructions you can find in the "Supply basic auth headers" section of the Basic Auth for REST API documentation page for Jira Cloud:

Supply basic auth headers

You can construct and send basic auth headers. To do this you perform the following steps:

  1. Generate an API token for Jira using your Atlassian Account.
  2. Build a string of the form useremail:api_token.
  3. BASE64 encode the string.
    • Linux/Unix/MacOS:
      echo -n user@example.com:api_token_string | base64
    • Windows 7 and later:
      $Text = ‘user@example.com:api_token_string’
      $Bytes = [System.Text.Encoding]::UTF8.GetBytes($Text)
      $EncodedText = [Convert]::ToBase64String($Bytes)
      $EncodedText
  4. Supply an Authorization header with content Basic followed by the encoded string. For example, the string fred:fred encodes to ZnJlZDpmcmVk in base64, so you would make the request as follows:
    curl -D- \
       -X GET \
       -H "Authorization: Basic ZnJlZDpmcmVk" \
       -H "Content-Type: application/json" \
       "https://your-domain.atlassian.net/rest/api/2/issue/QA-31"

 

 

Finally, for the future, please notice that this is not the best place to get help on development  related questions. The right resources are listed in https://developer.atlassian.com/resources. 

Specifically:

 

 

 

Cheers,
Dario

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events