How to get login user id in Jira cloud app


I created custom jira cloud app and installed. I followed this tutorial

Created form in html that is loaded in jira iframe. Afer form submitting i’m saving content into my DB. Multiple users installed same app and submitted form details. How can I uniquely identify which user submitted which data. Please guide me.

@Sankar if you are trying with spring boot application then try with following code (I have not tried)

public ResponseEntity<?> enabledEvent(@AuthenticationPrincipal AtlassianHostUser hostUser) {		
		Optional<String> user = hostUser.getUserAccountId();

from context also we can get as follows

  console.log("user account id (always present)", response.user.accountId);

Hi Prasad,

I’m not using spring boot application. I created form in my server and installed that using atlasian-connect json. Then my form showed in jira app. How can I get login user id into that form.

The second code snippet @prasad.rambanam provided is javascript. You can use it inside your forms onsubmit or wherver you send the data to your backend.

@Sankar You can identify users based on accountId :slight_smile:

console.log(“user account id (always present)”, response.user.accountId);

What’s the “AP” in above code.

atlassian javascript utilities, check the following document for more details

Getting error .
Uncaught ReferenceError: AP is not defined

I included
<script src="" async></script>
script also.

Try removing the async attribute

Removed. Error resolved but not getting user information.

          console.log("user id",;
          console.log("user key", user.key);
          console.log("user name", user.fullName);

Getting undefined.

It seems the above one is deprecated so try with following one

 AP.user.getCurrentUser(function(user) {
   console.log("The Atlassian Account ID is", user.atlassianAccountId);
1 Like

Hi Prasad,

Thankyou soo much. It’ working. :slight_smile: