


You should note that this works because the API and the UI are served from the same origin. The cookie will be sent back with each request that goes back and used to fetch the session data on the server side. The session id will be stored on the frontend as a cookie while session data is stored on the server side in memory or a storage store like Redis, MongoDB. In this process, Passportjs will create a session for the login if successful.

So here we have a setup where when a user clicks the login button, we make a POST call to our API to validate the user credentials. This one is based on a stateful authentication where session is stored on the server. Strangely, the code works ok when testing using the Firebase Emulator, but once it's deployed it stops working.I recently did a tutorial on how to do a cookie based stateless authentication on a NextJS app using JWT and PassportJS using GitHub OAuth API. I have followed the instructions in the passport-linkedin-oauth2 documentation, and the LinkedIn API keys are correct.Īs can be seen, I am getting around this by setting an isAuthenticated variable, but this naturally becomes an issue when I have multiple users. Also, the isAuthenticated variable remains false. When I try to authenticate with LinkedIn, I am redirected to the LinkedIn login page, but after successful login, the callback URL is not called, and the user object is not populated. Here is my code: const functions = require("firebase-functions") Ĭonst LinkedInStrategy = require("passport-linkedin-oauth2").Strategy Ĭonst session = require("express-session") Ĭonst )) į(req.isAuthenticated(), isAuthenticated) I am trying to integrate LinkedIn authentication using Passport in my Firebase Functions project.
