atlassian-api / atlassian-python-api

Atlassian Python REST API wrapper
https://atlassian-python-api.readthedocs.io
Apache License 2.0
1.29k stars 642 forks source link

Can't use oauth1 method #1284

Open Arlington1985 opened 6 months ago

Arlington1985 commented 6 months ago

Seems the framework doesn't fully support OAuth, is simply because I don't see it passed with get request as a header anywhere. https://github.com/atlassian-api/atlassian-python-api/blob/1ccaa1bbc4f5ad883d1b26cd75cf6f926a67a9b9/atlassian/jira.py#L88

Here is an example code how it's achievable with using requests library directly

import requests
from requests_oauthlib import OAuth1
from oauthlib.oauth1 import SIGNATURE_RSA

# OAuth1 parameters
access_token = "your_access_token"
access_token_secret = "your_access_token_secret"

# Jira API endpoint and issue key
jira_url = "http://localhost:8080"
issue_key = "ABC-123"

# Initialize OAuth1 authentication
oauth = OAuth1(
    client_key='OauthKey',
    resource_owner_key=access_token,
    resource_owner_secret=access_token_secret
    signature_method=SIGNATURE_RSA,
    rsa_key='generated private key',
    signature_type='auth_header'
)

# Make a request to get issue data
endpoint = f"{jira_url}/rest/api/2/issue/{issue_key}"
response = requests.get(endpoint, auth=oauth)

# Print the response
print(response.json())

Is there something I am missing?