After authenticating with a provider, an application will often receive both an ID token and an access token on behalf of the user. Now it seems there are two ways to assert who the user is.
Both seem like acceptable avenues, but are there certain scenarios in which one or the other should be used?
ID tokens are issued by the authorization server and contain claims that carry information about the user. They can be sent alongside or instead of an access token. Information in ID Tokens allows the client to verify that a user is who they claim to be.
ID tokens are JSON Web Tokens (JWTs) that conform to the OpenID Connect (OIDC) specification. They are composed of a set of key-value pairs called claims. Unlike access tokens, which are opaque objects that cannot be inspected by the application, ID tokens are meant to be inspected and used by the application.
An ID token is an artifact that proves that the user has been authenticated. It was introduced by OpenID Connect (OIDC), an open standard for authentication used by many identity providers such as Google, Facebook, and, of course, Auth0.
A dictionary containing app-specific state information needed to continue an activity on another device.
If you have both tokens and the ID token contains all info you need, you can use either way. Below are few differences that came to my mind:
Apart from the technical differences there's a semantic difference as well: the id_token
and the info in the there represents and identifies an authenticated user. That user is "present" and logs in to the application.
The access_token
and the information returned from the userinfo endpoint represents information about the user who issued the access token to the entity that presents it. That user doesn't need to be "present" or logged in (anymore).
An id_token
is typically "one-time usage" and an access_token
usually can be used for a short period of time.
Now in the case that both tokens are issued and received at the same time when a user logs in with OpenID Connect, the two overlap.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With