Summary
In this chapter, we learned that the browser has a handy fetch
function that allows us to interact with REST APIs. This allows us to specify HTTP headers such as authorization
, which we use to supply the user's access token in order to access the protected endpoints.
Leveraging the standard Auth0 JavaScript library allows single-page applications to interact with the Auth0 identity provider. It makes all of the required requests and redirects to Auth0 in a secure manner.
Using the React context to share information about the user to components allows them to render information and options that are only relevant to the user.
The AuthProvider
and AuthorizedPage
components we built in this chapter are generic components that could be used in other apps to help to implement frontend authorization logic.
Our app is very nearly complete now. In the next chapter, we are going to put...