Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Jira curl commad redirecting to authentication page

naresh n
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 19, 2021

Hi Everyone,

Companies authentication is SSO enabled with MSOffice . I am not able to connect to jira server using the below curl command. the error I am facing too follows below.

Can you please advise the right way to connect via rest api calls.

 

 

curl -D- \
> -u emailid@apitoken \
> -X GET \
> -H "Content-Type: application/json" \
> https:url/rest/api/3/issue/ticket-1234


% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0HTTP/2 302
server: awselb/2.0
date: Fri, 19 Mar 2021 09:55:27 GMT
content-type: text/html
content-length: 110
location: https://login.microsoftonline.com/

100 110 100 110 0 0 68 0 0:00:01 0:00:01 --:--:-- 68<html>
<head><title>302 Found</title></head>
<body>
<center><h1>302 Found</h1></center>
</body>
</html>

1 answer

0 votes
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 27, 2021

Hi Naresh,

I understand that you're Jira server site is integrated with an SSO.  However when you are trying to make a REST API call in this manner (using the -u switch in curl), your authentication request is being redirected to the SSO service in order to try to pass your username and API token there.  That likely will not work because the SSO provided does not know what your token is.

This presumes that you're using a version of Jira Server 8.14 or higher in which Personal Access Tokens are possible.  If you are using Jira Server 8.14 or higher with personal tokens, then you shouldn't pass that token with the -u but instead the token is expected to be passed using a header in the request, like so:

curl -H "Authorization: Bearer <yourToken>" \
-H "Content-Type: application/json" \
"https://{jiraBaseUrl}/rest/api/2/issue/{issueKeyorID}"

Jira server should be able to understand this request and process the results back to you without the need to contact the SSO authentication in this case.

If you happen to be using Jira Cloud, there is a slightly different means of authenticating using basic auth for the REST API, for Jira Cloud please refer to Basic auth for REST APIs.

I hope this helps.

Andy

Suggest an answer

Log in or Sign up to answer