i created bitbucket webhook api call supplied it with secret the secret token not generate.how to set secret ?. i have use requests methods
def create_hook(workspace_id):
# Build the URL for the workspace webhooks endpoint
url = f'https://api.bitbucket.org/2.0/workspaces/{workspace_id}/hooks'
auth = ("user_name", "password")
data = {
'url': 'https://demourl.com',
"name": "wehhook test secret",
"description": " new webhook test ",
'active': True,
'events': [
"pullrequest:approved", "repo:commit_comment_created",
],
"configuration": {
"secret": "abcdef",
}
}
# end the HTTP request to create the webhook
response = requests.post(url, json=data, auth=auth)
if response.status_code == 201:
return response.json()
else:
print("failed to create webhook", response.text)
return {}```
i want to secret token will generated ,how add secret in bitbucket webhook
There are multiple ways to authenticate to the Bitbucket Cloud REST API, but I think the easiest for you is using BASIC auth with an app password.
As a best practice, you should not encode the app password to your script, but store that in a Bitbucket repository secret.
Hello @Sagar Sukdev Navale ,
Welcome to Atlassian Community!
My understanding is that you are trying to create a webhook using the API endpoint Create a workspace webhook , and you would like to set a secret to this webhook. I'm afraid that currently, secrets are not available in Bitbucket Cloud webhooks, and this is the reason you are not being able to create a webhook with secrets using the API.
We do have an open feature request to implement secrets functionality to webhook, which you can check in the following link:
I would suggest you to add your vote there, since this helps both developers and product managers to understand the interest. Also, make sure you add yourself as a watcher in case you want to receive first-hand updates from that ticket. Please note that all features are implemented with this policy in mind.
You're also welcome to take a look at Bitbucket Cloud API reference to check the options available for the create webhook endpoint :
Thank you, @Sagar Sukdev Navale !
Patrik S
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.