They have a great intro video, watch it.
Our starter project already came with passport, so we'll just need to add passport-auth0 and express-session:
Yarn add passport-auth0 express-session auth0-lock
Looking at the architecture options, SPA+API looks like a natural fit to pursue: https://auth0.com/docs/architecture-scenarios/application/spa-api
You can also use the spa quickstart https://auth0.com/docs/quickstart/spa/react, that looks like it has some scripting that would be useful, I'll review that and compare in the next article.
You may also want to review JWTs as auth0 uses them, and they are beyond the scope of what I'm writing about in this series, I may get into some more detail later, but my focus with this series is not on JWTs.
First step, create a new account with the website name, then select Single Page App for the application type:


This
will then present you with a sample project you can download (that will have
your keys in it). I've downloaded mine,
it looks like the two files you'll need are in src/utils, with the rest of the
code showing how to integrate into your app.
The .env file in the root contains your auth0 clientid and domain. The code in src/views/Main/routes.js has
examples of how to protect routes using react-router. You can run the project itself using npm
start, it just serves up a page with a login control that opens the auth0 login
widget.
No comments:
Post a Comment