I have created a developer app and set the authentication to JWT as seen below.
{
"key": "com.<product_name>",
"name": "<Product Name>",
"description": "Product Desctiption....",
"vendor": {
"name": "Slik"
},
"baseUrl": baseUrl,
"lifecycle": {
"installed": f"{baseUrl}/installed",
"uninstalled": f"{baseUrl}/uninstalled"
},
"authentication": {
"type": "JWT"
},
"scopes": ["webhook", "repository"],
"modules": {
"webhooks": [
{
"event": "repo:push",
"url": "/webhook_listener"
}
]
}
}
When I create the app, I get a client_id and client_secret and once I connect the app to a workspace, I get the following info
key: <Same as Above>
clientKey: ari:cloud:bitbucket::app/<Workspace UUID>/<key (same as above)>
publicKey: <Public Key>
sharedSecret: <client_secret>
While trying to generate the JWT Token I am using the python library atlassian_jwt as follows:
import atlassian_jwt
token = atlassian_jwt.encode_token(http_method="GET", url="https://api.bitbucket.org/2.0/repositories/<workspace name>/<repo name>/diff/96c7b8e", clientKey=<clientKey that was generated above>, sharedSecret="<Shared Secret from above>")
The token I get here, when used to make the call to the URL "https://api.bitbucket.org/2.0/repositories/<workspace name>/<repo name>/diff/96c7b8e" results in a 401 unauthorised error.
Kindly let me know if I there is a mistake of some kind here which is causing this problem