I am using my Bitbucket APP password to list all my repositories.
However, I am unable to perform through REST API
import requests
import json
url = "https://api.bitbucket.org/2.0/repositories/MY-ORG?role=member"
headers = {
"Accept": "application/json",
"Authorization": "MY-APP-PASSWORD"
}
response = requests.request(
"GET",
url,
headers=headers
)
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))
Hi @Sudharsan S and welcome to the community!
An app password cannot be used by itself for authentication, like an OAuth access token. It needs to be used in combination with your Bitbucket account's username. You can find your username here https://bitbucket.org/account/settings/ after you log in to your account.
With curl, for example, you can use it as follows:
curl -u BitbucketUsername:AppPassword -X GET -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/workspace-id?role=member
Or with a basic auth header, where b64string is BitbucketUsername:AppPassword encoded in base64
curl -X GET -H "Authorization: Basic b64string" -H "Content-Type: application/json" https://api.bitbucket.org/2.0/repositories/workspace-id?role=member
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.