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

How to authentice with app password via Python requests?

Felipe Peter
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 25, 2022

I want to use Sphinx linkcheck to check the documentation of Python projects for dead links. Some links point to stuff on Bitbucket and I need to provide credentials to see if those links are still alive. The sphinx documentation explains how to add credentials but I am struggling to get them to work. The following minimal example always yields a response telling me that Bitbucket does not support account passwords anymore, although I am using an app password.

import requests

response = requests.get(
    auth=("my_email", "my_app_pasword"),
)
What credentials do I have to pass to the requests library to access that link?

1 answer

0 votes
Patrik S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 28, 2022

Hello Felipe,

Welcome to Atlassian Community!

I'm not really sure about the python syntax for that library, but looking at the example you shared, it seems like you are using the e-mail address as the username, and this is likely the reason why you are facing the authentication error.

To use basic authentication in calls to Bitbucket API you need to provide :

  • username : the bitbucket username of your account (not the e-mail address). You can check the username by going to your account's personal settings.
  • app password: a valid app password with the required permissions. The permissions necessary depend on the endpoint being called and are listed in the API documentation.

So in this case, you can try replacing the e-mail address with your bitbucket username and try executing the script again.

Hope that helps! Let me know if you have any questions.

Thank you, @Felipe Peter .

Kind regards,

Patrik S

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events