It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

REST APIv3 always returns 401 Unauthorized with OAuth2.0 Token Edited

I have been researching on how to access the /search?jql endpoint that now went 401 Unauthorized. It used to always return the data without any trouble.

Example request

curl -X GET 'https://icehousecorp.atlassian.net/rest/api/3/search?jql=project%20%3D%20ABV123%20AND%20issuetype%20%3D%20Story%20AND%20Sprint%20in%20openSprints%28%29%20and%20assignee%20%3D%20currentUser%28%29%20ORDER%20BY%20cf%5B10004%5D%20ASC%2C%20created%20DESC&fields=customfield_10004%2Csummary%2Cproject%2Ccustomfield_10007' -H 'Authorization: Bearer abc123'

I have asked for the user's consent for all of the scopes available there is, but it still gives me a 401 Unauthorized, with a response body

{"message":"Client must be authenticated to access this resource.","status-code":401}

 

1 answer

0 votes
Warren Community Leader Oct 25, 2019

Hi @Adam Fadhil S 

This generally happens because of a change made a few months ago, regarding the change from using a password to an API token. See this for further details

Hi @Warren the linked topic is about deprecation of using basic authentication with passwords and suggested us to use OAuth or API Token. I am currently using OAuth token, but still getting 401 Unauthorised. Do you have any other suggestions?

Warren Community Leader Oct 28, 2019

Hi @Adam Fadhil S 

Okay, then I would suggest using Postman (either online or download the app) - I've found it really useful. If it works in Postman, then there's something wrong with your curl statement

Hi @Warren ,

I am currently using Postman, the curL request is only for posting in here. And I still get the same error unfortunately.

What other factors should I bee looking into? I always clear my cookies when doing a request with Postman also.

Warren Community Leader Oct 28, 2019

Hi @Adam Fadhil S 

So re-reading your initial question, this used to work? The exact same API call / JQL / authorisation details used to work but now doesn't? If so, you may want to regenerate your API token and try again.

Possibly try with a much simplified call, something like ?jql=key=ABC-123 so that it is just trying to return one issue that you know you have access to.

Give us a screenshot of the Postman screen, with sensitive info (your API key) redacted.

Screen Shot 2019-10-28 at 15.47.10.pngScreen Shot 2019-10-28 at 15.37.52.png

Hi @Warren , the above are the Postman API Request using Postman and the consent asked to the user

Warren Community Leader Oct 28, 2019

Hi @Adam Fadhil S 

You're using Bearer for authentication, it should be Basic

Hi @Warren 

Are you sure? I am using OAuth2.0 authentication method. The response itself tells that the token_type is Bearer.

I've tried using Basic but it gives me a different 401 error.

 

Screen Shot 2019-10-28 at 16.45.25.png

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

309 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you