I created a token by referring this link, https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account. But did not work when used in the curl command.
curl --request GET --url https://reqcentral.com/ --user <user email>:<token>
Error:
<!-- HTTPError401 --><div class="aui-page-panel" ><div class="aui-page-panel-inner"><main role="main" id="main" class="aui-page-panel-content" ><div class="aui-page-header" ><div class="aui-page-header-inner"><div class="aui-page-header-main" ><h1>Unauthorized (401)</h1></div></div></div><div class="aui-message aui-message-warning warning"><p>Encountered a <code>"401 - Unauthorized"</code> error while loading this page.</p><p>Basic Authentication Failure - Reason : AUTHENTICATED_FAILED</p><p><a href="/secure/MyJiraHome.jspa">Go to Jira home</a></p></div></main></div></div>
I believe that because curl is using the --user switch, this is being treated as if it was a login attempt, hence why you're being prompted to go through a 2FA screen.
Instead take a look at our examples in Basic auth for REST APIs This document describes a different method that allows you to encode your emailaddress:api_token into a base64 string and then pass that string inside an authorization header. This method doesn't use the --user switch in curl, so it should allow you make such calls if your account as permissions to.
Andy
Hello, Good day. I would like to know whether this API token works using Postman client. You can use basic auth method (with user email address and API token as password). Thanks
Hi Manoj, Happy Day. I tried to access one of JIRA issue in postman, by passing my user emai & API token (which created through Atalassian account) in request payload. It redirected to microsoft login page. PFB screenshot. And could you please help to confirm , am i using correct API token or i should create token in JIRA - API token Authenctication section to authenticate JIRA
Yes, you are using the correct API token. https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/
You have configured two factor authentication or SSO in your environment ?
My JIRA env has two factor authentication. Once i logged in with my credentials, i will get authentication number in mobile authenticator app. once i submit the number it will redirect to my JIRA account.
Hi i tried with the example in the doc, by converting emailaddress:api_token into a base64 string and then pass that string inside an authorization header. Please find the screenshot. still getting Unauthorized error.
And need one clarification, for another application we have JIRA with atassian.net (EX: https://xyz.atlassian.net), there i can able to login with the token. But my application JIRA domine is https://reqcentral.com/ . it is not contains with atlassian.net. is it having any differences in this.com and .atlassian.net domine.
Since you're making a request to a non atlassian.net domain, you're not using Jira Cloud. As such the instructions in Manage API tokens for your Atlassian account don't apply here. Those instructions are only applicable to Atlassian Cloud sites.
Instead it seems likely you're using Jira Server or Jira Data Center, in which case, you would want to try to follow the documentation in Using Personal Access Tokens. The steps are slightly different there, but you will notice that this documentation has steps to include the authorization in a header instead of using the --user switch.
-H "Authorization: Bearer <Token>"
I realize that example in the documentation is for Confluence Data Center, but the concept is the same for Jira Server/Data Center editions that have personal access tokens.
Try that instead.
Thanks Andy, Using Bearer token i am able to login. But https://reqcentral.com/rest/api/2/issue/DCC-100 giving data. Could you tell me Why am not able to use v3 rest apis.
It looks like you're new here. Sign in or register to get started.