JIRA REST API Example - Basic Authentication

Applicable:

JIRA 5.0 and later.

JIRA allows REST clients to authenicate themselves with a user name and password using basic authentication .

Simple example

Most client software provides a simple mechanism for supplying a user name and password and will build the required authentication headers automatically. For example you can specify the -u argument with curl as follows

Supplying Basic Auth headers

If you need to you may construct and send basic auth headers yourself. To do this you need to perform the following steps:

  1. Build a string of the form username:password
  2. Base64 encode the string
  3. 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.

Authentication challenge

Because JIRA permits a default level of access to anonymous users, it does not supply a typical authentication challenge.

Some http client software expects to receive an authentication challenge before it will send an authorization header and this may mean that it may not behave as expected. In this case you may need to configure it to supply the authorization header as described above rather than relying on its default mechanism.

Powered by Confluence and Scroll Viewport