Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the identity of the connected user via the Bitbucket REST API?

in the Stash REST API, after having retrieved an OAuth token, I'd like to get the identity of the connected user (username, email, ...). But I can't find a resource in the doc that let me do it without knowing the username at least.

Is there a way to achieve this without knowing the username?

In JIRA, there seems to be a resource to do this:

"/rest/gadget/1.0/currentUser"

but I couldn't find something similar in Stash.

like image 513
Pascal Paulis Avatar asked Sep 29 '14 09:09

Pascal Paulis


People also ask

How do I find my bitbucket user ID?

On the sidebar, click on the Profile picture > View profile. Then on the sidebar click on "Settings" and you will be able to find your username.

What is bitbucket REST API?

Bitbucket Data Center's REST APIs provide access to resources (data entities) via URI paths. To use a REST API, your application will make an HTTP request and parse the response. The Bitbucket Data Center REST API uses JSON as its communication format, and the standard HTTP(S) methods like GET, PUT, POST and DELETE.

How can I get access token from bitbucket?

To generate a personal access token from within Bitbucket Server go to Manage account > Account settings > Personal access tokens. Admins cannot create tokens for users. Admins can change and revoke tokens from the users personal tokens page. Use permissions to get the correct access for different users.


1 Answers

You can retrieve the username of the currently authenticated user by doing a GET to the following resource (relative to the base URL of your Stash server):

/plugins/servlet/applinks/whoami

You can then use this username to retrieve the rest of the user's profile data from the REST API.

like image 172
Pascal Paulis Avatar answered Oct 06 '22 16:10

Pascal Paulis