Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

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

Mauricio Mondragon June 10, 2022

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
Atlassian Team members are employees working across the company in a wide variety of roles.
June 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 

Mauricio Mondragon June 14, 2022

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."
  }
}
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
June 17, 2022

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
Mauricio Mondragon June 24, 2022

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
Atlassian Team members are employees working across the company in a wide variety of roles.
June 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
AUG Leaders

Atlassian Community Events