restbitbucket-serverbitbucket-api

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.


Solution

  • 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.