I'm building a system with OIDC and OAuth 2.0 (using Auth0), and I'm unsure how to properly use the id_token
and access_token
. Or rather, I'm confused about which roles to assign to the various services in my setup.
I have a fully static frontend-application (single-page app, HTML + JS, no backend) that ensures that the user is authenticated using the implicit flow against Auth0. The frontend-application then fetches data from an API that I am also building.
Now, which is right?
- The frontend SPA is the OAuth client application
- My API service is an OAuth resource server
...or:
- The frontend and my API service are both the client application
If both my frontend and backend API can be considered to be the client, I see no real harm in using the id_token
as the bearer token on requests from my frontend to my backend - this is appealing because then I can simply verify the signed token on the backend, and I have all the information about the user that I need. However, if my API is considered a resource server, I should probably use the access_token
, but then I have to connect to Auth0's servers on every API request to both verify the token, and get basic user info, won't I?
I've read this which seems to suggest that the access_token
is the only valid token for use with my API. But like I said, I'm not sure about the roles of the individual services. And using the id_token
is tempting, because it requires no network connections on the backend, and contains information I need to extract the right data.
What is the right way to go about this?
** 6 Client validates the tokens and retrieves the End-User's Subject Identifier.**
– ApostolicI've read this
link in your OP is 404'ed. Is there an updated page you know about? – Platitudinize