PassportJS - Failed to find request token in session


I was working with PassportJS to authenticate to Meetup using Meetup strategy. But this error drove me insane for hours.

Error: Failed to find request token in session

I'll show you one of the causes and how to fix it.


There are many good tutorials on how to set up PassportJS so I will skip on this. Refer to these tutorials on how to setup PassportJS.

You can follow along, source code is available on GitHub (refer to README on how to run it)

Error Message

This is the full error message returned while trying to authenticate with Meetup.


Here is the video of error generated



The error occurred due to Expression Session cookie.secure value.


According to Expression Session documentation setting cookie.secure to true requires an HTTPS enabled site. But it's rarely the case that your development server is HTTPS enabled.

You could set the cookie.secure value to false while developing and set it to true for production by checking process.env.NODE_ENV.

But you can do better by setting cookie.secure value to a non-Boolean value, auto, which will automatically set to true or false depending on the security of current connection.


Running the updated code

Let's update the cookie.secure value to auto and try again.


And :awyeah:


it works 🎉


I've only discussed one possible cause for "Error: Failed to find request token in session" error message.

There are literally dozens of causes and fixes available when you Google it.