Getting 401 error for a valid Bitbucket user account, when trying to access API from Jira cloud

ppushpam April 22, 2022

Hi,

I am trying to invoke Bitbucket API from Jira using automation rule. I used a service account created in Bitbucket for authorization, it was working fine but recently we had an Atlassian outage which was there for 7 days. After that, our old app pwds were invalid so created a new app pwd, and converted it to base64 "username:apppwd" and using this string to invoke the API, but I am getting 401 error.

When I tried my personal username, its working fine and not working with service account, the service account status is enabled in Bitbucket. Could you please help.

Thanks

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 25, 2022

Hi @ppushpam,

I would suggest checking the following:

1) Have you generated the app password for the service account or for your personal account?

If you are using the username of the service account, the app password should be generated for the service account.

Please make sure that the app password has enough permissions for the operation you want to perform.


2) After you generate the app password for the service account, can you try running the API call with curl from your terminal, for testing purposes?

An example would be the following:

curl -u username:app-password https://api.bitbucket.org/2.0/repositories/workspace-id

replace username and app-password with the values for username and app password of the service account, and also the API URL with the one you are using.

What is the output of this call in your terminal?

Kind regards,
Theodora

ppushpam April 25, 2022

Hi @Theodora Boudale ,

Thankyou for your response!

1. I created the app pwd for the service account, providing it full access and admin access. 

2. I used the curl command and output is authorized, I got "200" response.

Creds issue.PNG

But when I am using it in the Jira automation rule, it says unauthorized. I converted "username:app-password" to Base64 string and using it in the header as :

Authorization: Basic "Converted string" 

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 26, 2022

Hi @ppushpam,

Thank you for the info. Could you please try one more thing:

Run from terminal

curl -v https://api.bitbucket.org/2.0/repositories/workspace-id/ -H "Authorization: Basic converted_string"

where

https://api.bitbucket.org/2.0/repositories/workspace-id/ Replace with the API URL you use in your Jira Automation rule

converted_string replace with your Base64 string without any extra quotes

and let me know the output you get (200 or 401). This is to double-check whether the issue may be with the converted string.

Kind regards,
Theodora

ppushpam April 26, 2022

Hi @Theodora Boudale ,

Please find the output of curl command in the attached image, it doesn't contain whole output, Let me know if you want the full output content.

Bitbucket_output.PNG

ppushpam April 27, 2022

Hi @Theodora Boudale ,

Following up on the issue, was this output helpful to interpret the cause?

ppushpam April 27, 2022

Hi @Theodora Boudale ,

The issue is fixed now, Thanks a lot for your help.

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 29, 2022

Hi @ppushpam,

It's good to hear that the issue has been fixed. Was there a problem with the converted string? The output you posted in the attached image shows a 401 response as well, so I would assume that the culprit is with this string.

Kind regards,
Theodora

ppushpam May 2, 2022

Hey @Theodora Boudale ,

Looks like there was some confusion with the service account username I was considering, later i used the correct username and it worked ass expected.

Thanks

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 4, 2022

Thank you for the update on this, I'm glad you figured this out.

Please feel free to reach out if you ever need anything else.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events