Unauthorized: Could not find stored client data for <clientKey>. Is this client registered?

I’m trying to build an app using the atlassian-connect-express example and am having trouble with the PROD environment installation. My app installs fine, but then I run into the error message below when viewing the app in my browser.

Unauthorized: Could not find stored client data for . Is this client registered?

I think the issue is me not storing/recalling the JWT correctly. I’m receiving it in the lifecycle.installed step but I can’t find any documentation on what to do with it or how to recall it properly.

Any help would be greatly appreciated!

I figured this out, and it might be because I don’t like to read docs but things were very unclear for me so I’m posting hoping this might help someone else.

The issue for me came down to the lifecycle.installed path, which I thought I needed to handle myself through express, but it turns out that ACE handles this for you??

Removing my app.post(’/installed’… from my routes/index.js, rebuilding and installing solved the problem.

1 Like

Hi @x2boarder,

Indeed, ACE handles /installed web-hook so you don’t have to.

If you still want to perform some actions upon installation, you can do it this way:

addon.on('host_settings_saved', (clientKey, {eventType}) => {
    // your code goes here
}

Cheers,
Jack

1 Like

Hi @jack,
your approach works for me, but the code I need to run on ‘host_settings_saved’ uses an instance of addon.httpClient in it to make REST API calls.

addon.httpClient get initialized with the req variable to be able to authenticate API REST calls, how could I use the req object created with the /installed POST call?

Replying to myself:
I found this post and learned that there is no need for the full req object to initialize addon.httpClient, it is possible to use only the clientKey:

addon.on('host_settings_saved', (clientKey, {eventType}) => {
    addon.httpClient({
        clientKey: clientKey
    });
});
1 Like

To troubleshoot this issue further,
I have my connect app hosted at a certain domain and listed it as private in the Marketplace.
The installation via private upload in Jira and Confluence cloud went fine, but after say 3 weeks,
both plugins display the “Unauthorized: Could not find stored client data for …”.

Both apps are listed as installed in the manage apps page.
Could this be caused by a restart of Atlassian cloud servers due to an update?

We had to uninstall and reinstall the apps in order to get it working again.
Am I missing something?

Hi @11142

Were you able to fix the issue. We are getting the same error whenever the app gets restart.
We need to either reinstall or upgrade the app.

As per our findings, the Addonsetting does not executes automatically after restart

This is critical for us and any help would be appreciated.
Thanks

Unfortunately, I am getting this issue on my app which worked for more than 2 years. This is affecting the prod app and we are concerned about the clients.