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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With