Downloading Attachment From Jira and avoiding SSO

I’ve been trying to use python to download attachments from our company’s JIRA.
I’m using this library ->
We’re using an SSO solution called ‘Okta’ and the thing is, when trying to use
It tries to retrieve the file without using the REST API, and without passing the token.

When I tried to use this URL with requests.get and passing the right credentials and apikey I got into our SSO login page :frowning:

Is there a way to download attachments from an issue using REST API?
Or is there any other solution available?

Attaching sample code:

from jira import JIRA
import requests

options = {"server": ""}
username = "user"
apikey = "key"
issue_key = TEST-01

jira = JIRA(options, basic_auth=(username, apikey))
issue = jira.issue(issue_key)
first_attachment = issue.fields.attachment[0]
    data = first_attachment.get() # fails
except Exception as ex:
    print("Failed getting attachment")

# succeeds but returns an HTML with the following data `Since your browser does not support JavaScriptyou must press the Continue button once to proceed.\n `
data = requests.get(first_attachment.content, auth=requests.HTTPDigestAuth(username, apikey)).content