Hi there!
I am trying to set up a new Atlassian Connect app that clients will install to their Jira project. This app will need to do specific API calls to Jira, mainly creating issues.
I set up the app and got the info from the /installed
call in the lifecycle of the app, and I’m trying to use the atlassian_jwt
Python package to generate the token with the data I got from the lifecycle.
However, every request I make seems to get a 401 error. Here is an example of the code I tried, with removed secrets:
client_data = {
"key": "com.example.myapp",
"clientKey": "<key>",
"publicKey": "<public key>",
"sharedSecret": "<shared secret>",
"serverVersion": "100212",
"pluginsVersion": "1001.0.0-SNAPSHOT",
"baseUrl": "https://<url>.atlassian.net",
"productType": "jira",
"description": "Atlassian JIRA at https://<url>.atlassian.net ",
"eventType": "installed"
}
token = atlassian_jwt.encode_token('GET', '/rest/api/2/issue/NP-1', **client_data)
print(token)
r = requests.get('https://<url>.atlassian.net/rest/api/2/issue/NP-1,
headers={'Authorization': 'JWT ' + token, 'Content-Type': 'application/json'})
Any idea what am I doing wrong?
I hope to use the Jira package instead of requests if possible, but one step at a time. Thank you!