Forest cannot authenticate the user for this request

@GuillaumeGautreau Getting error Forest cannot authenticate the user for this request. on all the environment (DEV,STAGE,PROD). Everything was working fine till yesterday we didn’t made any changes in the deployment in any of the environment. Today while accessing to Forest admin getting above error. Please help us asap as it is impacting for Production environment.

Hi @Vishnu_Gupta :wave: can you share with us your project name and more informations, i you have, about your issue :pray:

@Arnaud_Moncel Thanks for the quick response. Here are the details below.

Project Name - finicity-reports
Package Name - forest-express-moongose
Package Version - 8.7.4

Hello @Vishnu_Gupta,

Can you please give more details about this error? Do you observe it on the frontend, on your agent? Do you have any logs to share?

If the error is on the frontend, could you please open the network tab of the developer tools of your browser, and refresh? Then could you please share the details about the call that is failing.


@GuillaumeGautreau @Arnaud_Moncel Please see the error on the front end Your password is incorrect. Please try again

Error on the backend

[2022-07-26T11:50:22.209Z] - OPTIONS /forest/stats/Report?timezone=Asia%2FCalcutta 204 1.491 ms

[2022-07-26T11:50:22.250Z] - OPTIONS /forest/stats/Report?timezone=Asia%2FCalcutta 204 2.151 ms

[2022-07-26T11:50:22.534Z] - POST /forest/stats/Organization?timezone=Asia%2FCalcutta 401 3.826 ms


code: '',

message: 'Forest cannot authenticate the user for this request.'


[2022-07-26T11:50:25.626Z] - POST /forest/sessions 401 4.319 ms 

Hello @Vishnu_Gupta,

It seems that you recently upgraded the version of forest-express-mongoose, because the last version that is referenced in our backend is version 6.7.2 for almost all of your environments.

Between v6 and v7 we changed the way users are authenticated. And here, it seems that the application is still expecting a v6 agent.

I have multiple solutions for you:

  • If you did not upgrade on purpose, then the solution might be to rollback to v6
  • If you did upgrade on purpose, you need to:
    • Follow the documentation to upgrade from v6 to v7
    • Follow the documentation to upgrade from v7 to v8
    • Do the upgrade first on your staging environments, and then on your production. The file .forestadmin-schema.json needs to be up to date with the right reference of the version you’re using. Production environments don’t generate this file, but development environments do it on startup.

@GuillaumeGautreau Everything had been working fine till yesterday. Liana version was 8.7.4 on DEV and STAGE environment was able to access the forest admin. Why suddenly nothing is working on any environment. We have followed all the solutions provide in the upgrade document.

Yes, we first upgrade on our non prod environment (DEV and Staging). Today when we deployed on Production non of the environment is working.

We are getting frustrated with this. Our customer is getting impacted on Production :frowning:

@GuillaumeGautreau Package lock version

"forest-express-mongoose": {
      "version": "8.7.4",
      "resolved": "",
      "integrity": "sha512-iFbq22XzRMsY6ZHTICAP8A4Tj8XB4JkF1rrvqnKnzesLcUTN7x1jzu50dhx7WQrNnAfXDptP4WUvCZWbJjxaVA==",
      "requires": {
        "@babel/runtime": "7.15.4",
        "bluebird": "2.9.25",
        "forest-express": "9.5.0",
        "http-errors": "1.7.2",
        "lodash": "4.17.21",
        "moment": "2.29.2",
        "moment-timezone": "0.5.27",
        "semver": "5.6.0"

Forestadmin-schema.json file

"meta": {
    "liana": "forest-express-mongoose",
    "liana_version": "8.7.4",
    "stack": {
      "database_type": "MongoDB",
      "engine": "nodejs",
      "engine_version": "16.13.0",
      "orm_version": "5.13.14"


I don’t see how it could have been working on dev and staging before, maybe the new code was not running as you expected, because it is still referenced with the version 6.7.2 in our DB.

Currently, your environments don’t send the apimap to our server, or maybe there is a problem with this. Do you have access to logs?

Can you copy/paste your environment variables (without the env secret and the authentication secrets, please)?

@GuillaumeGautreau Restarted my dev environment and liana version dump up to 8.7.4 as mentioned the apimap file was send correctly on dev below is the logs

[forest] 🌳🌳🌳  Your configDir ("/home/app/server/forest") does not exist. Please make sure it is set correctly.
Tue, 26 Jul 2022 13:56:52 GMT body-parser deprecated undefined extended: provide extended option at server/lender-portal-server-app.js:161:20
(node:11) DeprecationWarning: Mongoose: the `isAsync` option for custom validators is deprecated. Make your async validators return a promise instead:
Listening on port 8080
index created successfully
[forest] 🌳🌳🌳  Checking need for apimap update...
[forest] 🌳🌳🌳  Sending schema file to Forest...
[forest] 🌳🌳🌳  Schema file sent.

Restarted the stagting environment liana version didn’t bumped up. Please see the logs

[forest] 🌳🌳🌳  Checking need for apimap update...
[forest] 🌳🌳🌳  No change in apimap, nothing sent to Forest.

How can I update the liana version on staging environment?

Ok, this dev environment is correctly saved on our side.

You need to copy your .forestadmin-schema.json file in your staging environment for it to be sent. I suppose that you have NODE_ENV=production on staging, which prevents the schema to be updated on startup.

@GuillaumeGautreau .forestadmin-schema.json file is same on my dev and stage environment (we use Gitlab for deployment). Then what can be the issue. We have NODE_ENV=production on all the environment so it should not have been worked on dev environment right?

@GuillaumeGautreau Is there any way you all can update the schema or liana version from backend?

Can you copy and paste here the content of the meta property of schema files from the production and staging environments please?

Also, can you check that your production and staging environments use the right configuration:

  • Production, FOREST_ENV_SECRET ending with 96
  • Stage environment, FOREST_ENV_SECRET ending with 2e

One possibility can be that all of your servers are sharing the config from the dev environment, which could explain the error the frontend gets.

@GuillaumeGautreau Verified both the FOREST_ENV_SECRET are same ending with 96 for production and 2e for staging

meta property of schema files from the production and staging environment.

  "meta": {
    "liana": "forest-express-mongoose",
    "liana_version": "8.7.4",
    "stack": {
      "database_type": "MongoDB",
      "engine": "nodejs",
      "engine_version": "16.13.0",
      "orm_version": "5.13.14"

Can you copy/paste the whole config without secrets (or keep the last 2 characters of the env secret) please?

It seems that you managed to make it work on your environment named Stage. Can you explain what you did?

In our backend, I can see the correct version number for your agent.

@GuillaumeGautreau We updated the forest-express-moongose to the latest version in which the moment vulnerability was resolved. Deployed the changes to dev and stage as there was a changed in the .forestadmin-schema.json the apiMap was sent and the liana version updated to 8.7.4

Last time same thing happened when we updated to forest-express-moongose version 8.7.4 schema and liana version got updated to 8.7.4 and suddenly it rolled back to 6.7.2 which started causing us the authentication issue.

Any suggestion what all measure need to be taken while going on production?

I’m not sure to understand the state of your installation right now, but do you have a working environment on stage, with the version 8?

Did you manually rollback to v6? What was the reason if it was the case?