Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Getting 401 unauthorized error python after trying everything

Hi All, please help. I tried everything still getting 401 unauthorized error in python. Below is my code.

url = ''
server = ''

headers = {
'Authorization': 'Basic [base64 encoded string of my office email id:auth token]'
options = {

query = {

response = requests.get(url,headers=headers,params=query)

Please help. I am exhausted trying every page on this community and you tube videos, nothing is working :(


PS can this be because our company uses OKTA to login into apps?

however NOTE - when I am opening below URL in my browser its showing all information



Many thanks


2 answers

0 votes

Hello @Vibhor Malik 

The reason why the GET works in your browser is that it's already passed through the OKTA 2FA sequence when you logged into the Jira web GUI and has a session cookie, so it's pre-authenticated :)

I'm currently working in an environment that uses OKTA for 2FA login to Jira for their users, but to work around this to access their Jira Cloud REST API without having to enable and use OAuth, I got the company's firewall admins to add a whitelist rule to allow the connection to the REST API over port 43 as an exception. Once that was done, everything was fine and I was able to use the normal Key / Token and bundle it into a Basic auth session over HTTPS.

Most companies are understanding enough to allow these sorts of small, special purpose exception cases to OKTA, provided they know why you're doing it and trust you.

If the company won't allow that sort of OKTA bypass, then they'll have no choice but to enable the application linking for you, and you'll have build the 3LO sequence into your python.

Hi @David Bakkers Many thanks for the information. This is really helpful.

One quick question - as I am able to get all info in the browser, is there any way to retain that information? OR I was reading somewhere that we can use JSessionID  or session cookie to read info from browser in any tool.

Is there any way I could browser info because I only need to GET info and not POST it and how to do it in python?



Hello @Vibhor Malik 

If you want to keep the JSON output from the REST API that is shown on the browser window, it's just text so you can either copy and paste it into a text file, or use the browser's Save function to keep it. Raw JSON isn't very readable, so it's a good idea to use a browser side add-on that parses the JSON and converts it back to human readable text. Firefox has a built-in JSON parser where Chromium based browsers need an extension.

As for for some other browser side app or tool re-using the same session cookie that was created after logging into Jira, it's not likely; the cookie is unique and specific to that login session only and cannot be used for anything else. Modern web browsers do session sandboxing to stop apps in one window from accessing the cookies of other apps in other windows as a deliberate security feature.

Thanks @David Bakkers 

However manual copy pasting would be a tedious task as I have to go through issue 1 to issue 2500 till date and counting more in future

so I may have to work on some loop in python and use that info which is displayed in browser. Is there any way we can do this?


As far as reading Json is concerned I am only interested in task close date so I can create a method or RegEx to pick that info from it. 


Thanks again


Sorry not the issue closed date - because that was available in excel download directly from Jira. I am interested in only a date when the issue was changed to one XYZ specific status, which sadly is not available in excel/CSV/XML download form Jira.

Hello @Vibhor Malik 

Yes, doing all the work in Python is of course much, much faster than copying and pasting requests one at a time into a browser window.... but since you asked if it was possible, I just advised that it was.

Look through the REST API documentation. For every single endpoint it provides an example of how to construct a request in Python.

As for how to build Python scripts to then display the results in a browser window... that is a huge subject that is beyond the scope of this discussion.

Sorry @David Bakkers , didnt mean to offend. I only wanted to clarify my ask. :) 

Also I am actually asking that - 

is there a way I can loop the issue number in URL,  and when URL hits and it shows Json info in the browser, I pick that one info I need and save somewhere (all this using python)


Please suggest. You really had been of great help till now. :) 

Hello @Vibhor Malik 

To me it sounds like you're asking "Can you please write some Python code for me that does XYZ"

If that is the case, I would suggest there are plenty of free online tutorials that will guide you through how to write in Python, and literally thousands of examples of using Python to interact with REST APIs in general, or Jira specifically.

I wish you the best of luck on your learning adventure.

Hi @David Bakkers 


No I actually meant if that is feasible? and if yes - if you can head me to right direction  like a link or video which explains it how?

because I do know little bit of scraping and when trying with Selenium and BeautifulSoup (after opening the URL) it still gives me 401 unauthorized error.




0 votes

Okta doesn't support basic authentication, you'll need to use Oauth, Andy gives us a good guide to this at

Hi @Nic Brough -Adaptavist- Thanks for the reply. 

I checked into this - however the steps to use Oauth need to create an application link in Jira. (here) - however my company doesnt give me access to go  to Jira settings, so I cant get past by this step.

Is there any way I can setup or you can help set this up?

If not possible - I only need data from Jira. and I can see that data in lot of text format when I paste this link in browser '

Is there a way to extract that data from browser by scraping or any other way to python?



Suggest an answer

Log in or Sign up to answer

Atlassian Community Events