Hello everyone,
I had a funcional script (python 3) doing dailly backups of all repos from a team, and since 2020-08-28 it stops working, and while I was trying to see where was the issue, by changing username to email and even changing password from my atlassian account, I start received error 401 while obtaining the list of repos from the team through that script. I tried with both username and email but same outcome:
response> <Response [401]>
Here is the url that I am using, with login:
import requests
# Request 100 repositories per page (and only their slugs), and the next page URL
next_page_url = 'https://api.bitbucket.org/2.0/repositories/%s?pagelen=100&fields=next,values.slug' %team
#print ('next_page_url> \n%s'%next_page_url)
# Keep fetching pages while there's a page to fetch
full_repo_list = []
while next_page_url is not None:
response = requests.get(next_page_url, auth=(username, password))
print ("response> %s" %response)
page_json = response.json()
print ("page_json> %s" %page_json)
# Parse repositories from the JSON
for repo in page_json['values']:
full_repo_list.append(repo['slug'])
# Get the next page URL, if present
# It will include same query parameters, so no need to append them again
next_page_url = page_json.get('next', None)
# Result length will be equal to `size` returned on any page
print ("Result: \n", len(full_repo_list))
I have already recheck the password and its the right one.
I really dont know what and why I am still getting the 401 error.
Anyone?
Hello,
For API calls you need to use username for authentication, the email is used for authentication on the website only.
A few things you can try:
Can you try executing the following on a terminal and see if you get the same response or not? This is to narrow down whether the issue is specific to the script or not.
curl -L -X GET --user username:password http://api.bitbucket.org/2.0/repositories/<workspace>/
where username and password replace with the values for your account, and <workspace> replace with the workspace ID for the team.
Can you try generating an app-password for your account and see if this works for you in the curl command above and also for your script?
You can find the documentation on generating an app-password here:
Kind regards,
Theodora
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.