Hi,
I created an app that uses oauth2 to ask for consent from the user in order to perform actions on their behalf.
I added the the following permissions and scopes as per Jira webhook API reference
`read:fiield:jira`, `write:webhook:jira` and `read:project:jira`.
I successfully complete the oauth2 flow and obtain the token pair.
With the token I want to create a webhook using the API.
I tried using the token to get other resources and it's working. I am able to fetch the users issues and other resources.
I decoded the JWT on https://jwt.io and I see the correct scopes in the claims.
First I tried the official recommended way with the API token:
webhook_api_url = "https://my-instance.atlassian.net/api/rest/3/webhook"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
}
auth = HTTPBasicAuth("email@example.com", "my-api-token")
request = {
"url": "https://example.com",
"webhooks":[{"events": ["jira:issue_created", "jira:issue_updated"]}]
}
response = requests.post(webhook_api_url, headers=headers, json=webhook_data, auth=auth)
I get a `401`: `Client must be authenticated to access this resource.`
Then I tried using the Bearer token:
webhook_api_url = "https://api.atlassian.com/ex/{my-id}/rest/webhooks/1.0/webhook"
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": f"Bearer {my-token}"
}
request = {
"name": "my webhook",
"url": "https://example.com",
"events": ["jira:issue_created", "jira:issue_updated"],
}
response = requests.post(webhook_api_url, headers=headers, json=webhook_data)
I get a `401`: `Unauthorized; scope does not match`.
Can someone help me with which request I am supposed to make?
I solved it by giving my app the manage:jira-webhook classic permission.
It didn't work with the granular ones.
Hi @stevan ,
Maybe it's the "name" field in the webhook. A name field is not defined in the documentation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.