Missed Team ’24? Catch up on announcements here.

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

Bitbucket Cloud REST API v2.0 - Making a request with authentication

Miguel Ángel García Gómez August 27, 2018

Hello all,

I'm trying to make a REST API request using API docs, but I don't understand how to make a request with authentication. In this case, I have follwed this guide, but I don't know how to obtain "client_id" specified in the first step.

What I want to do is:

Therefore, what is the best approach to do this? What I need to make the request autheticated?

Thank you very much.

Regards,

Miguel. 

1 answer

1 accepted

0 votes
Answer accepted
Battlebeard
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 29, 2018

Hi Miguel,

Thanks for reaching out to the community, my name is Nero and I am here to help.

So the client_id you are looking for can be found in the bitbucket settings for your site. This guide can show you how to set up an OAuth consumer if you haven't done so.

Once you have done this you will be able to see your key (the key is the client_id you where missing) and secret on the OAuth settings page:

Screen Shot 2018-08-29 at 08.29.58.png

Additionally, as I am unsure what language/approach you are using I can recommend checking out these bitbucket repos which have a number of examples on both Oauth and OAuth2

OAuth Examples

OAuth2 Examples (only Java and Javascript currently available)

I hope this helps, however, if you would like some more help with this it would be hand if you could provide some examples of your work so far so I can get a better understanding of any further sticking points you may have.

Best,

Nero 

Miguel Ángel García Gómez August 29, 2018

Thank you very much for your response Nero.

The scenario that I want to create is:

* From Jira Server: If the user make an issue transition (for example, from "In progress" to "Done"), and if the issue has a Pull Request associated, automatically merge this PR in a Bitbucket cloud account.

My first approach was doing this with a REST API request, from a script in the transition post-function. This script would make a request, first to obtain Bitbucket credentials, and then make a request to "merge" endpoint, with the JWT token obtained.

While I have done more research, I saw that is possible to make requests from linked applications in Script Runner. But then, I've realized that Jira Server and Bitbucket cloud are linked via DVCS connector. So I've read that is possible to use this plugin directly from a script. Therefore, it's possible to get the PR associated with the issue, but now I need to do more research to see if it's possible to make the merge operation with this PR obtained.

What I want to know is if this last approach is better than the first one, or vice versa.

If you need more information I'll try to be clearer.

Thanks!

Regards,

Miguel.

Battlebeard
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 31, 2018

Hi Miguel,

Sorry for the delay in coming back to you. I have read through your response and I do believe that using the native integrations via DVCS is the better option.

I would imagine that in your research you have come across this Connect Bitbucket Cloud to Jira Software Server, but I thought I would link it just in case.

As for the functionality, this page gives a good overview Jira/Bitbucket Integration and you may also find this article useful 6 things you should know before & after integrating Jira Software Server with Bitbucket Server (it is server to server but mostly still applicable when using Bitbucket Cloud)

Do reach out to us again if you have any further questions.

Best,

Nero :D

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events