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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
Andy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since this site you are connecting to is a Jira Server or Jira Data Center edition, there is no v3 of the REST API for that product yet, only v2. Reference the Server API documentation over in Jira Server platform REST API reference instead in this case. The Jira Cloud REST API reference won't necessarily apply in this case, since this is not Jira Cloud.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the information, Andy. We have AWS Data Center based Jira setup, so we cannot get REST API V3 functionality, am i correct? And does Atalazian have any plans to support AWS Data Center based Jira ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Jira Cloud and Jira Data Center are technically different products. In turn they actually have different REST APIs, as linked to above. Right now, only Jira Cloud has a v3 of the API, and that v3 is still currently in beta. I don't know of any plans to introduce a v3 API to Jira Data Center.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks. Even with 2FA API token should help. https://developer.atlassian.com/cloud/jira/software/basic-auth-for-rest-apis/. Is it possible for you to test with 2FA ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.