Proof of Concept
1. Add your own .env (from .env.examplef)
2. Add your Sanity credentials to sanity/sanity.json
3. yarn install
yarn dev 🚀
- The frontend request login directly from Auth0.
- The frontend reciews a callback containing the session token.
- The frontend calls our backend using the session token.
- The backend validates the token using the Auth0 API.
- If the user is valid we search Sanity to find the user.
- Return the userdata 🎉
The frontend is the offical Auth0 react sample app. The only thing added is a hook that calls our /backend
which again calls Sanity to get the user data.
The backend is a Node/Express application, it has one route that take a request and returns the userdata is the user is authenticated correctly:
The Sanity config and Studio. We are using a private dataset for the userdata and an API key.