# Downloading Attachment From Jira and avoiding SSO

**URL:** <https://community.developer.atlassian.com/t/downloading-attachment-from-jira-and-avoiding-sso/41048>\
**Category:** Everything Else\
**Tags:** sso, python, jira, rest-api\
**Created:** [August 25, 2020, 10:31am UTC](https://community.developer.atlassian.com/t/downloading-attachment-from-jira-and-avoiding-sso/41048 "2020-08-25T10:31:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TalMaimon](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@TalMaimon](https://community.developer.atlassian.com/u/TalMaimon)\
**Post date:** [August 25, 2020, 10:31am UTC](https://community.developer.atlassian.com/t/downloading-attachment-from-jira-and-avoiding-sso/41048/1 "2020-08-25T10:31:26Z")

</div>

Hey!  
I’ve been trying to use python to download attachments from our company’s JIRA.  
I’m using this library → [https://jira.readthedocs.io/en/master/api.html](https://jira.readthedocs.io/en/master/api.html)  
We’re using an SSO solution called ‘Okta’ and the thing is, when trying to use  
`attachment.get()`  
It tries to retrieve the file without using the REST API, and without passing the token.

 ![image](https://global.discourse-cdn.com/atlassiandeveloper/original/3X/c/2/c2cc85d15135fac036f12426585d888d5774d0c0.png)

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

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

Attaching sample code:

```auto
from jira import JIRA
import requests

options = {"server": "https://some_url.com/"}
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]
try:
    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

```
