Which url i have to use in callback url if i connect with jira
Asked by Mauricio Mondragon:

I have a task in jira, and I want to use a automation rule.

With this rule I want to run a pipeline in bitbucket.

I create an oauth consumer in the repository, but when I generate an access token and make the post request I get and status code 500.

![Captura de Pantalla 2022-06-10 a la(s) 13.07.22.png](https://community.atlassian.com/t5/image/serverpage/image-id/201543i17267BB4B3E1CC08/image-size/large?v=v2&px=999 "Captura de Pantalla 2022-06-10 a la(s) 13.07.22.png")![Captura de Pantalla 2022-06-10 a la(s) 13.06.52.png](https://community.atlassian.com/t5/image/serverpage/image-id/201544i329AAB60FAC60DAF/image-size/large?v=v2&px=999 "Captura de Pantalla 2022-06-10 a la(s) 13.06.52.png")


Answers:
author: Patrik S
body: Hello [@Mauricio Mondragon](/t5/user/viewprofilepage/user-id/4917137) ,

Thank you for reaching out to Atlassian Community!

With regards to the call-back URL, it's only really needed if you are using an OAuth flow that involves a web browser. From my understanding, you are trying to build an automation in Jira that just involves API calls, so you can put any URL as the callback URL such as <https://localhost> or <https://bitbucket.org>, as it will not impact the token that will be provided.

Having said that, in order for us to investigate further I would need to have more information about what are the details of your API call :

* What is the OAuth flow you are currently implementing to get the token for authentication? Is it client credentials ? You can find all the available OAuth flows in our API reference documentation :
  * <https://developer.atlassian.com/cloud/bitbucket/rest/intro/#authentication>
* Which is the specific endpoint of the API you are trying to call?
* Could you please share with us the content of the body and all the headers you are using in your request to the API?
* If you try to run the same API call locally, using the same authentication method as your Jira automation, do you get the same error?

Thank you, [@Mauricio Mondragon](/t5/user/viewprofilepage/user-id/4917137) .

Kind regards,

Patrik S

comments: author: Mauricio Mondragon
body: hi [@Patrik S](/t5/user/viewprofilepage/user-id/4603309)

Thank you for replying.

In my automation rule I?m send web request to this url

* <https://api.bitbucket.org/2.0/repositories/my> workspace/ my repository/pipelines/

My headers are

Content-Type application/json

Authorization Bearer + token  

I tried generating the token by client credentials and Authorization code, but the status response is 500 by this methods.

My body request is:

{  
"target": {  
"ref-type": "branch",  
"type": "pipeline_ref_target",  
"ref_name": "master"  
}  
}

I'm based on this documentation

<https://docs.getxray.app/display/XRAYCLOUD/Taking+advantage+of+Jira+Cloud+built-in+automation+capabilities#TakingadvantageofJiraCloudbuiltinautomationcapabilities-BitbucketCloud/Pipelines>

In this documentation mentioned a basic authorization but with this type of auth I get this response:

Bitbucket Cloud recently stopped supporting account passwords for API authentication. See our community post for more details: <https://atlassian.community/t5/x/x/ba-p/1948231> App passwords are recommended for most use cases and can be created in your Personal settings: <https://bitbucket.org/account/settings/app-passwords/> For more details on API authentication methods see our documentation: <https://developer.atlassian.com/cloud/bitbucket/rest/intro/#authentication>

If I use an app pasword I get this response:

\* Basic \<app_password\>

400 "Invalid Authorization header"

\* Bearer \<app_password\>

401

```
{  "type": "error",  "error": {    "message": "Access token expired."  }}
```


author: Patrik S
body: Hello [@Mauricio Mondragon](/t5/user/viewprofilepage/user-id/4917137) ,

Thank you for providing more details.

I think the issue here is that you are not providing the correct authentication credentials to the API calls in your automation.

My suggestion here is that you use Oauth client credentials flow, so when you create an Oauth consumer under your workspace settings, you will be provided with a key and secret.

The automation would consist in two steps :

#### 1. Get the access_token by providing the credentials of your OAuth consumer : {#toc-hId-148303954}

You need to call the access_token endpoint to get a Bearer token that will be used in the later step to call the actual Bitbucket API you are looking for. You need to configure the step in your automation as per the below example:

![](https://getsupport.atlassian.com/secure/attachment/7384676/7384676_image-2022-04-21-09-59-16-033.png)

The parameters used are the following :

```
URL: https://bitbucket.org/site/oauth2/access_tokenHeaders : 
authorization : Basic <Base 64 encoded "key:secret">Content-Type : application/x-www-form-urlencodedBody: grant_type=client_credentials
```

Please note that in the authorization header you have to provide the **base64** encoded value of your OAuth key and secret. On mac you can base64 encode a string using the following command :

```
echo -n "KEY:SECRET" | base64
```

#### 2. Call the Bitbucket API endpoint providing the access_token from the previous step {#toc-hId--1659150509}

You need to use the **access_token** you got in the step above to authenticate the call to Bitbucket API endpoint you want, as the following example :

![api call jira automation.png](https://community.atlassian.com/t5/image/serverpage/image-id/202408iBF07C6AD76246D7A/image-size/large?v=v2&px=999 "api call jira automation.png")

The parameters are :

```
URL: https://api.bitbucket.org/2.0/< Endpoint >Headers : Content-Type : application/jsonAuthorization : Bearer {{webResponse.body.access_token}}
```

Could you please try configuring as the suggestion above and check how it goes?

Thank you, [@Mauricio Mondragon](/t5/user/viewprofilepage/user-id/4917137) .

Kind regards,

Patrik S


author: Mauricio Mondragon
body: hi [@Patrik S](/t5/user/viewprofilepage/user-id/4603309)

I followed your instructions and it works for my automation rule.

Now when I request run a pipeline I get a successful response.

Thanks for your help. This was very helpful.


author: Patrik S
body: Hey [@Mauricio Mondragon](/t5/user/viewprofilepage/user-id/4917137) ,

You're very welcome!

Happy to have been of some help :)

Kind regards,

Patrik S


Tags: bitbucket-cloud

cloud