TL/DR: (Why) does a name/PAT combination created in the Bitbucket web UI not work with Bitbucket REST API (or repo cloning)?
I've been reading various documentation on Bitbucket REST API and Personal Access Tokens, with the intent of using the latter when invoking the former.
All that I have read so far have said -- in more elaborative words -- that this is possible.
Following along, I created a Personal Access Token (PAT
) in the Bitbucket web UI.
Per the screenshot below (posted at the bottom, so as to not break up the text flow), the PAT
Name is "test", and let's say the PAT
value is Rzg4MGUyN4m4N9U3O1HQHO3ABJyp7xClvsan7sAmFEPy
Why, when I try to use this PAT
, do I get an "Authentication failed" error? For example:
user@bld_svr:~$ curl -L -u test:Rzg4MGUyN4m4N9U3O1HQHO3ABJyp7xClvsan7sAmFEPy -H "Content-Type: application/json" -X POST https://bitbucket.svr.com/rest/build-status/1.0/commits/5764bb32f80813b3bbcbf6496c113c1830c52bb0 -d '{"state":"INPROGRESS","key":"job_434","url":"http://bld_svr:8080//blue/organizations/jenkins/prj/detail/prj/434/pipeline"}'
{"errors":[{"context":null,"message":"Authentication failed. Please check your credentials and try again.","exceptionName":"com.atlassian.bitbucket.auth.IncorrectPasswordAuthenticationException"}]}
My readings have led me to believe that all that's necessary is:
- Creating the
PAT
in the Bitbucket UI - Using the Name/
PAT
combination the same as one would use username/password
Trying to debug the issue a little, this page, specifically, indicates that Name/PAT should be usable to git clone
repos. But that also fails:
$ git clone https://bitbucket.svr.com/scm/key/a_project.git
Cloning into 'a_project'...
Username for 'https://bitbucket.svr.com': test
Password for 'https://test@bitbucket.svr.com': # I typed in "Rzg4MGUyN4m4N9U3O1HQHO3ABJyp7xClvsan7sAmFEPy" here
fatal: Authentication failed for 'https://bitbucket.svr.com/scm/key/a_project.git/'
Can anyone give me the straight dope on the Bitbucket PAT
s and how they should be configured/used with Bitbucket REST API, and even just plain git clone
ing?