How to enable jwt in ACE?

I am using ACE and node.js, but I cannot get jwt to work.
I would like to know how to enable jwt in ACE.
Is there anything else that I am missing?
What I do know is the following.

  1. setting atlassian-connect.json “authentication”:{“type”: “jwt”}
  2. use “addon.authenticate(true)”

Hi @Lucias_Alcard ,

Have you been following the instructions in https://bitbucket.org/atlassian/atlassian-connect-express/src/master/? Can you explain what you’ve done so far and where you are stuck.

Regards,
Dugald

hi @dmorrow

Thanks for the reply.
I’m referring to it.
jwt is temporarily enabled, but after a while I get a 401 error.
I have searched the documentation with no good results.

Hi @Lucias_Alcard ,

jwt is temporarily enabled

Does this mean your app is able to successfully make API calls for a period of time? If they start failing, maybe check your code to ensure it’s not re-using a JWT such that it expires and becomes invalid.

Regards,
Dugald

@dmorrow ,

jwt is temporarily enabled

This was a mistake in my code.
It has never actually passed authentication.
I always get this error." Authentication verification error (401): Could not find authentication data on request"

Hi @Lucias_Alcard ,

It’s really helpful that you included the full error response because this tells me it’s coming from https://bitbucket.org/atlassian/atlassian-connect-express/src/94e6707b974db7770eda9fced59ee0ce9d1f10fd/lib/middleware/authentication.js#lines-51 which is called when your app handles a request from Jira. I previously assumed your app couldn’t call a Jira REST API.

I’m not sure why the calls are failing though. You may need to provide more details to help further such as explaining what steps you’ve done and possibly sharing some code.

Regards,
Dugald

hi @dmorrow

I think my code mostly follows the tutorial.

Full error

{ ctx: {} } Authentication verification error (401):  Could not find authentication data on request
::ffff:[myaddres] - - [04/Aug/2021:03:23:30 +0000] "GET /hello-world?xdm_e=https%3A%2F%2F[mydmain]&xdm_c=channel-com.example.myapp__hello-world&cp=&xdm_deprecated_addon_key_do_not_use=com.example.myapp&lic=none&cv=1001.0.0-SNAPSHOT HTTP/1.1" 401 826 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.107 Safari/537.36"

atlassian-connect.json

{
    "name": "Hello World",
    "description": "Atlassian Connect app",
    "key": "com.example.myapp",
    "baseUrl": "[mydmain]",
    "vendor": {
        "name": "Example, Inc.",
        "url": "http://example.com"
    },
    "authentication": {
        "type": "jwt"
    },
    "lifecycle": {
        "installed": "/installed" ,
        "uninstalled": "/uninstalled",
        "enabled": "/enabled",
        "disabled": "/disabled"
    },
    "scopes": ["READ","WRITE"],
    "apiVersion": 1,
    "modules": {
        "generalPages": [
            {
                "url": "/hello-world",
                "key": "hello-world",
                "location": "system.top.navigation.bar",
                "name": {
                    "value": "Greeting"
                }
            }
        ]
    }
}

index.js

export default function routes(app, addon) {
  app.get('/', (req, res) => {
      res.redirect('/atlassian-connect.json');
  });

  app.get('/healthCheck', (req, res) => {
    res.status(200).send({ status: 'ok' });
  });

  app.get('/hello-world', addon.authenticate(true), (req, res) => {
    res.render(
      'hello-world.hbs',
      {
        title: 'Atlassian Connect'
      }
    );
  });
}

I re-installed the app in jira and it fixed the problem, but I’m not sure what caused it.
I’m going to post this in a new topic because another new problem has arisen.