Is it possible to find out the logged in user on an Atlassian Connect page?

Hi everyone,

I have a backend application that I want my Connect app to communicate with. The backend app has Atlassian authentication so it knows about their account id etc. The Connect app is served via NodeJS Express and has a React SPA.

When a user opens up my Connect tab on their instance, I’d like to safely communicate who that logged in user is so I can display relevant/personal information to them. Is that possible? I’m also open to any other suggestions. For example, I can serve the Connect app from the same domain and set a cookie there and use it in the requests but that’s not really a secure way to go.

Hi @msa. Welcome to the developer community! There is a REST API method for getting the current user: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-myself/#api-rest-api-3-myself-get

In a Connect app, you can use the AP object and call that method above like so:

AP.user.getCurrentUser(function(user) {
    console.log(“Welcome ”, user.displayName);
});

Let me know if that’s helpful info, or if I didn’t grok your question properly. :slight_smile:

1 Like

Hi @nmansilla,

Thank you for a quick response. When I use AP.user.getCurrentUser I only get the field atlassianAccountId and nothing else.

Let me rephrase my question:

  1. I have a web application that allows authentication with Atlassian
  2. I have an Atlassian Connect application that has:
    2.1 a React SPA
    2.2 an Express App

I want to be able to send an authenticated request to my web application from either the Atlassian Connect React SPA or the Express backend.

I think what I need to do is to follow these guidelines:

I’m currently having an issue with the JWT token as the response I’m getting back is {"error":"invalid_grant","error_description":"The signature of the bearer token was invalid."}