How to make Bitbucket API calls with access token?

Dear Atlassian,

I created an ASP.NET MVC application which can authorize the user at Bitbucket. I used CSharp.Bitbucket library to get the token secret and token value.

The OAuth tutorial said that with the token I can make API calls.

I know that I can call the API using basic authorization like this way:

 string url ="https://bitbucket.org/api/1.0/user/";
 var request =WebRequest.Create(url)asHttpWebRequest;
string credentials =Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes("username"+":"+"password"));
request
.Headers.Add("Authorization","Basic "+ credentials);
 
using
(var response = request.GetResponse()asHttpWebResponse)
 {
  var reader =newStreamReader(response.GetResponseStream());
  string json = reader.ReadToEnd();
 }

But how can I call the API using the access token?

Thank you very much!

Yours faithfully,

Gábor Domonkos

1 answer

Hi,

I managed to do this by using the OAUTH token and the secret:

curl "https://bitbucket.org/api/1.0/repositories/YOUR_USER/YOUR_REPOSITORY?oauth_token_secret=YOUR_SECRET&oauth_token=YOUR_TOKEN"

But note that this only seems to work for GET requests. I was not able to use this with a POST (e.g., create a pull request comment).

Hope this helps.

Cheers,

Michael

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 06, 2018 in Bitbucket

Do you use Bitbucket Cloud and Jira Cloud? If so, let us know!

Hi Community, I'm Julia and I'm on the Jira Software Cloud marketing team!  We're looking for companies or teams using Bitbucket Cloud and Jira Software Cloud. If your team fits the t...

143 views 6 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you