Get appSession token in React app from NodeJS backend

Hello,

I am using Auth0 in a NodeJS based backend application where in an API endpoint, I have the following check:

if (!req.oidc.user) {
    res.status(401).json({ message: "User is not logged in." });
    return;
}

In the React frontend, I need to make an authenticated request to that API endpoint. I need the appSession token for that to pass as a cookie in my Axios request from frontend.

It is supposed to be onClick event for POST’ing data in a particular user’s profile, but for that I need the token in the frontend.

Help would be appreciated.

Hi @ritik,

Welcome to the Auth0 Community!

It sounds like you should be using an Access Token for this request. Here’s an example of how to get it and send it in your React app:

And here’s an example of consuming it in an Express API (you don’t necessarily have to use Express, just makes it easier):

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.