I can't request bitbucket rest api with right username and password, and the status code is 403.

yue wang February 21, 2022

hello!

when I use bitbucket rest api like https://api.bitbucket.org/2.0/repositories/{workspace}/ to get repositories, the return status code is 403 and content is 'b'Too many invalid password attempts. Log in at https://id.atlassian.com/ to restore access.\n''.

But my username and password is right , I can use them login  https://id.atlassian.com/ through broswer.

I use python package requests do my request, the code like this:

from requests.auth import HTTPBasicAuth
import requests

username = "{username}"
password = "{password}"
email = "{email}"
worksapce = "{worksapce}"
BITBUCKET_URL = "https://api.bitbucket.org/2.0"
BITBUCKET_AUTH = HTTPBasicAuth(username, password)
BITBUCKET_HEADERS = {"content-type": "application/json"}

response = requests.get(f"https://api.bitbucket.org/2.0/repositories/{worksapce}/",
params={
"pagelen": 100
},
auth=BITBUCKET_AUTH,
headers=BITBUCKET_HEADERS)

print(response.status_code)

print(response.content)
print(response.json())

please help me! Any help would be highly appreciated.

Thanks in advance!

1 answer

1 accepted

0 votes
Answer accepted
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 23, 2022

Hey Yue!

 

The error which you have specified indicates to me that Git is unable to authenticate the password associated with the user.
I have some suggestions:
  1. Reset the password associated with the account if you intend to use regular username/password basic auth (this is being deprecated on 01/03/22): https://id.atlassian.com/login/resetpassword 
  2. If this does not work, instead of using the normal account password can you try setting up an App Password and replacing the basic password with the app password?
    https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/
  3. To set up the App Password, you can navigate to the account settings here once logged into that account - https://bitbucket.org/account/settings/app-passwords/
    You can create the App Password and give it the permissions it needs accordingly.
-
If the regular password has been changed instead (option 1), please ensure it is cleared from any applications/GIT clients, keychain access (Mac), credential manager (Windows), deleted from /etc/shadow directory (Linux).
Let me know if this helps.
- Ben (Bitbucket Cloud Support)
yue wang February 23, 2022

Thank you for your help! Your second resolution can work, first not!

Thank you again!

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events