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

app password fail

Miao Miao Li March 14, 2021

I created an app password in bitbucket, and then called the app password. I used http basic authentication to call the rest api of bitbucket, and it kept returning unauthenticated.

3 answers

1 accepted

0 votes
Answer accepted
Miao Miao Li March 15, 2021

I have solved it, just remove the request body, a strange error message

0 votes
Miao Miao Li March 15, 2021

I can use the same account to correctly access the api I just posted after logging in to bitbucket in the browser

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 15, 2021

Hi @Miao Miao Li ,

When you create an app password, you select specific permissions for it. One possibility is that the app password does not have enough permissions for the endpoint you are using. E.g. if you're trying to read pull requests via API and the app password does not have permissions to read pull requests, then the request will fail.

Since it is not possible to view the permissions of an existing app password, I would suggest creating a new one, double check that it has appropriate permissions for the API endpoint(s) you want to use, and then make a new call with the new app password and see if it works.

If you're still having issues, please let me know:

1.  the exact API call you are making
(please feel free to replace the actual workspace-id and the repo name in the URL when you paste it here, with something like <workspace-id> and <repo-name>)

2. what is the exact response you are receiving when you make the call

so I can better help you.

Kind regards,
Theodora

Miao Miao Li March 15, 2021

When I generated the app password, I checked all the permissions. When I call the api, it still returns 401. The api I called is this https://api.bitbucket.org/2.0/repositories/ncs-nxp?page=1

Miao Miao Li March 15, 2021

I tried to replace ncs-nxp with workspace-id, but it still doesn’t work

Miao Miao Li March 15, 2021
header.put("Content-Type","application/json");
String auth="email:apppassword";
header.put("Authorization","Basic "+base64(auth));

This is the code I used for authorization

Miao Miao Li March 15, 2021

@Theodora Boudale  hello,Can you help me? I tried replacing the email address with user_name in Bitbucket profile settings, and the result will become 403 (http status)

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 16, 2021

Hi @Miao Miao Li ,

For API calls the Bitbucket username should be used, instead of the email. The email is only used for logging in to Bitbucket website. For operations like cloning/pulling/pushing via HTTPS and also for API calls, the username should be used instead.

You mentioned that you solved this by removing the request body, I'm glad you managed to figure this out.

I am not sure though what request body you were using? An API call to retrieve a workspace's repos doesn't require you to send additional data with a request body.

Kind regards,
Theodora

Miao Miao Li March 16, 2021

Just some test data, forgot to remove it. Well, the username must be the username in the account settings, not the login email address

Miao Miao Li March 16, 2021

There is an inaccurate record of the last access time on the app password, it is often not updated. If that is accurate, maybe I can find some problems earlier.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events