How to login to OKTA and access an app using python for automation purpose

Hello All, As part of my organization I’m planning to get a list of Jira tickets and update the ticket in Jira. For this, I need to authenticate to OKTA and then access the Jira app. I’m trying to automate this scenario and I’m able to login with basic auth but every request that I try for getting the apps from okta is giving me 401 error. Can someone guide me on how to automate this kind of scenario/ whats wrong with the below code? Any help would be appreciated. Thanks.

import requests
url = “
payload = “”"{
“password”: “PASSWORD”,
“username”: “”,
“options”: {
“warnBeforePasswordExpired”: true,
“multiOptionalFactorEnroll”: false
headers = {
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’
response = requests.request(“POST”, url, headers=headers, data = payload)

get the session token for accessing the okta apps

okta_token = response.json()[“sessionToken”]
headers= {
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’,
‘Authorization’: 'SSWS '+okta_token

wanted to login to okta and then login to jira and access a ticket something like below

jira_url = “

apps_list_url = “
response = requests.request(“GET”, apps_list_url, headers=headers)

where SSWS token is, you need to provide not a session token, but API token which is generated by Okta Admins in Security -> API -> Tokens

@phi1ipp Can you show an example of how to call the API token in python?

@Bushbaker27, check this as one of the examples - though it uses okta python sdk