Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,503
Community Members
 
Community Events
165
Community Groups

Which url i have to use in callback url if i connect with jira

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.pngCaptura de Pantalla 2022-06-10 a la(s) 13.06.52.png

 

 

1 answer

0 votes
Patrik S Atlassian Team Jun 14, 2022

Hello @Mauricio Mondragon ,

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 : 
  • 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 .

Kind regards,

Patrik S 

hi @Patrik S 

 

Thank you for replying.

 

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

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."
  }
}

Hello @Mauricio Mondragon ,

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 :

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: 

The parameters used are the following : 

URL: https://bitbucket.org/site/oauth2/access_token

Headers : 

authorization : Basic <Base 64 encoded "key:secret"> Content-Type : application/x-www-form-urlencoded Body: 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

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

The parameters are : 

URL: https://api.bitbucket.org/2.0/< Endpoint >

Headers : 
Content-Type : application/json
Authorization : Bearer {{webResponse.body.access_token}}

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

Thank you, @Mauricio Mondragon .

Kind regards,

Patrik S

Like Mauricio Mondragon likes this

hi @Patrik S 

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.

Like Patrik S likes this
Patrik S Atlassian Team Jun 24, 2022

Hey @Mauricio Mondragon ,

You're very welcome!

Happy to have been of some help :) 

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket

Git push size limits are coming to Bitbucket Cloud starting April 4th, 2022

Beginning on April 4th, we will be implementing push limits. This means that your push cannot be completed if it is over 3.5 GB. If you do attempt to complete a push that is over 3.5 GB, it will fail...

2,230 views 2 9
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you