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

REST API Authentication problem

extralucide
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!
April 24, 2022

Hi

I created a project on bitbucket and created a pull request.

https://bitbucket.org/<my_pseudo>/<my_repo>/pull-requests/1/

I create an app-password

Now I would like to retrieve pull request information with "curl" and REST API.

I try 

curl -v -u <my_login>:<my_app_password> https://api.bitbucket.org/2.0/repositories/test/pull-requests

No response but verbose says that:


* Trying 18.205.93.8:443...
* Connected to api.bitbucket.org (18.205.93.8) port 443 (#0)
* schannel: disabled automatic use of client certificate
* schannel: ALPN, offering http/1.1
* schannel: ALPN, server accepted to use http/1.1
* Server auth using Basic with user '<my_login>'
> GET /2.0/repositories/test/pull-requests HTTP/1.1
> Host: api.bitbucket.org
> Authorization: Basic b2xpdmllci5hcHBlcmU6SlV5OFljQzdhUzVTRm1QcXhQN1k=
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 401 Unauthorized
< Server: nginx
< Vary: Origin
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="Bitbucket.org HTTP"
< Content-Type: text/plain
< X-B3-TraceId: a0259912425ae7e4
< X-Usage-Output-Ops: 0
< X-Dc-Location: Micros
< Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
< Date: Sun, 24 Apr 2022 09:41:27 GMT
< X-Usage-User-Time: 0.009101
< X-Usage-System-Time: 0.004353
< X-Served-By: 13ec9c009674
< ETag: "d41d8cd98f00b204e9800998ecf8427e"
< X-Static-Version: 9c0ba0615ff1
< X-Render-Time: 0.0149459838867
< Connection: keep-alive
< X-Usage-Input-Ops: 0
< X-Version: 9c0ba0615ff1
< X-Request-Count: 2147
< X-Frame-Options: SAMEORIGIN
< Content-Length: 0
<
* Connection #0 to host api.bitbucket.org left intact


I search here https://developer.atlassian.com/cloud/bitbucket/rest/intro/ but I miss a tutorial for absolute beginner

Thanks

Olivier

1 answer

0 votes
Karthick S
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 25, 2022

Hello @extralucide

Welcome to Atlassian Community!

You may use this API to get PR details 

Sample CURL call as below:

curl -X GET -u username:AppPassword "https://api.bitbucket.org/2.0/repositories/workspaceID/repo_slug/pullrequests/1"

Kindly replace with the workspace ID, repo slug & PR number. 

I hope this helps.

Kind regards,

Karthick S

Praveen Kukreja September 20, 2023

Hi @Karthick S

is the snippet you provided above still valid ? I am getting 401 in the response.

I took a quick look in the community posts and found a post mentioning that basic auth with password is deprecated

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 20, 2023

Hi Praveen,

We have indeed deprecated the use of account passwords for Git over HTTPS and API. An account's password can be used only for logging in to the website from browser.

You can use an app password instead, as indicated in the call that Karthick provided. You can read more about app passwords here:

username should be the Bitbucket username of the account you generated the app password for (it can be found here: https://bitbucket.org/account/settings/).

Kind regards,
Theodora

Like Praveen Kukreja likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events