Passing Access Token from Auth0 auth response from clientside to serverside in nextjs
Unanswered
Sokoke posted this in #help-forum
SokokeOP
What are some of the ways to pass access token from Auth0 authentication response to server side in nextjs and use that to fetch data from external api in server component in nextjs. (almost all api endpoints need access token to access the data)
We are creating a application which we use nextjs for frontend and ssr to fetch data, auth0.js, a client side library for authentication handled on the client side, and we have a backend team to build an external api using flask. So far, we want to fetch almost all data on the server side , so here are a few options we considered, but don't know their pros and cons.
1. use nextjs server to serve as a proxy (basically forwarding my access token and the request to nextjs server and then fetch external api)
2 .passing the access token as a header from client side to server side, and then fetch from serverside (how would you do it exactly?)
3. server-side redirect (don't know how that would work)
The auth0-nextjs SDK is not an option because we are doing embedded login, and auth0-nextjs sdk only support universal login, which means user will be redirected to their login page, and we think is bad UX.
We are creating a application which we use nextjs for frontend and ssr to fetch data, auth0.js, a client side library for authentication handled on the client side, and we have a backend team to build an external api using flask. So far, we want to fetch almost all data on the server side , so here are a few options we considered, but don't know their pros and cons.
1. use nextjs server to serve as a proxy (basically forwarding my access token and the request to nextjs server and then fetch external api)
2 .passing the access token as a header from client side to server side, and then fetch from serverside (how would you do it exactly?)
3. server-side redirect (don't know how that would work)
The auth0-nextjs SDK is not an option because we are doing embedded login, and auth0-nextjs sdk only support universal login, which means user will be redirected to their login page, and we think is bad UX.