How to act as a app user in a Connect App

We are using atlassian connect express on Node.js and are having trouble acting as a app user. The App user exists in jira and we can assign him but we haven’t been able to use his account programmatically.

We tried to act as the user like:

httpClient.asUserByAccountId('<AccountIDAppUser>').get('/rest/api/latest/myself', function(err, res, body) {
	     console.log("Body: ", body);
	     console.log("ERR: ", err);

but we get the error:

It is no Problem to impersonate my account that is used to install the app.

In fact we want to be able to do the same API calls like acting with my own account.
I see the app user data in the install lifecycle but I don’t know how to use them to authenticate/act as the app user.

Thank you in advance for your support.

Hi @aam,
please try with httpClient.authenticatedAsAddon() instead of httpClient.asUserByAccountId('<AccountIDAppUser>') and let us now if it was helpful :slight_smile:

Have a nice day,

Hi @BeataSzturemska ,

I just tried it but I get:

My Code is:

 let httpClient = addon.httpClient(req);
    httpClient.authenticatedAsAddon().get('/rest/api/latest/myself', function(err, res, body) {
      console.log("Body httpClient: ", body);
      console.log("ERR httpClient: ", err);

Sorry, my bad!
I assumed it’s Java, not JS.

I need to do some research but based on readme it’s just httpClient.get('/rest/api/latest/myself', function(err, res, body) {}

How to send a signed outbound HTTP request back to the host
ACE bundles and extends the request HTTP client. To make a JWT signed request back to the host, all you have to do is use request the way it was designed, but use a URL back to the host's REST APIs.

var httpClient = addon.httpClient(req);
httpClient.get('/', function(err, res, body) {

Hope that this time I’m right.

1 Like

Thank you @BeataSzturemska for the fast reply.