"Unable to authenticate you" for prod/staging rails apps - works for dev

Expected behavior

I can fire up Forest like I can for my dev environment

Actual behavior

I get a “Unable to authenticate you” message for both my staging and production environments


Rails 5.2.3 on Heroku (heroku-20 stack)
forest_liana 6.04 gem

  • I’ve set the environment variables and restarted heroku per the getting started instructions
  • I set up roles for the environments
  • Per another thread, I tried to access Forest on both Chrome and Safari… but …

Looking at network requests, Forest is getting a 500 when making a request to [my-server]/forest/authentication

My staging application_url: https://dispatch-er.herokuapp.com

  • Package Version: forest_liana 6.04
  • Express Version: n/a
  • Sequelize Version:n/a
  • Database Dialect: postgres
  • Database Version: current heroku Postgres… unlikely relevant
  • Project Name: Dispatch

Hello @Kevin_Davis and welcome on our community forum, :slight_smile:

To understand what’s going on with the authentication I would need you to send me your server logs with the error details please.

In this case it will be easier for us to help you solve this problem

Thanks for the quick response!

I’m off to bed, but here is the relevant log line… unfortunately I don’t see anything else that matches

From the server:

Mar 9 18:17:13  dispatch-prod  app[web] INFO  I, [2021-03-10T02:17:13.231686 #4]  INFO -- : [4fae1822-e6e3-4100-a585-a6190a200696] method=POST path=/forest/authentication format=*/* controller=ForestLiana::AuthenticationController action=start_authentication status=500 duration=778.47 view=0.57 db=0.00

I can see earlier during setup there was an issue with retrieving an IP whitelist, but that went away after I set the config vars and restarted

Also, I can see that some setup requests succeeded

Mar 9 16:35:13  dispatch-prod  app[web] INFO  I, [2021-03-10T00:35:13.277491 #4]  INFO -- : [e77837da-7e9a-438e-8b6c-2e926f71ad0f] method=GET path=/forest/ format=*/* controller=ForestLiana::ApimapsController action=index status=204 duration=1.80 view=0.00 db=0.00

Ok, thanks for the logs! Can you try to authenticate and share us from your browser network logs the request that fail? :slight_smile:

Here’s the full info from the network tab:

The preview shows…

    "errors": [
            "status": 500,
            "detail": "The registration to the authentication API failed, response: {\"error\":\"invalid_redirect_uri\",\"error_description\":\"redirect_uris must only contain strings\"}"

Hey @Kevin_Davis,

It could be related to this part of the documentation:

Did you setup the application url for your production/staging environment :thinking: ?

Aha! my fault… the code is set up correctly, but I somehow set the ‘APPLICATION_URL’ instead of ‘FOREST_APPLICATION_URL’

Seems to be working now! Thanks!

1 Like

Glad to hear that :grinning_face_with_smiling_eyes: