K
Kinde6mo ago
Joe

Authentication issue after login. Node Express SDK.

Hi, I am trying to get integration with my express/node server up and running, I can login, and get redirected, but using the quick start code from the experess SDK app.get("/", (req, res) => {     if (req.session && req.session.kindeAccessToken) {         res.send("You are authenticated!");     } else {         res.send("You are not");     } }); - I have interrogated the req.session and it looks like this: | Session { 1|app | cookie: { 1|app | path: '/', 1|app | _expires: 2023-12-12T16:28:39.653Z, 1|app | originalMaxAge: 86400000, 1|app | httpOnly: true 1|app | }, 1|app | kindeState: 'afae3ce6c4851292227f2639575c0d61d8897cc799704574cacc45af', but the req.session..kindeAccessToken is undefined and if I run the verifier middleware I get JWTParseError: Empty JWT Any help would be appreciated Cheers Joe
3 Replies
Joe
Joe6mo ago
should I receive a Authorisation Header in the return? - because I don't - I get
Joe
Joe6mo ago
No description
No description
No description
onderay
onderay6mo ago
@Joe you should be getting it in the header in the return. Here are a few things you can check: Make sure you're correctly setting up the Kinde SDK in your Express application. The setupKinde function should be called with the correct configuration. Check the callback URL in your Kinde application settings. It should match the URL where your application is running. Ensure that your application is correctly handling the callback from Kinde. After a successful authentication, Kinde will redirect the user back to your application with a code in the URL. Your application should exchange this code for an access token. If you're using the protectRoute middleware, make sure it's being used correctly. This middleware will check if the user is authenticated and if not, it will redirect the user to the Kinde login page. If you're still having issues, could you provide more details about your setup? That would help me assist you better. For example, how are you setting up the Kinde SDK in your application? How are you handling the callback from Kinde? Are you using the protectRoute middleware? Any additional information would be helpful.