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>
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.