All Articles
BLOG

ID Token vs. Access Token: Understanding the Rollup ID Difference

August 11, 2023
|
Adrian Maurer (@a11hard)
  • ID vs. Access Tokens: While both tokens play crucial roles in authentication and authorization, they serve distinct purposes. The ID token verifies a user's authentication, while the access token grants permission to access specific resources.
  • Misuse Risks: Using the ID token to call an API can expose applications to security threats. Conversely, access tokens should be treated as opaque strings by client applications, ensuring they're used solely for their intended purpose.
  • Rollup ID's Role: By understanding and correctly utilizing ID and access tokens within Rollup ID, developers can provide a secure and seamless user experience, leveraging the platform's robust authentication and authorization capabilities.

"Should I use the ID token or the access token to secure this API call? The ID token seems more intuitive since it tells me who the user is, which could help in making better authorization decisions, right?" If you've found yourself pondering this, you're not alone. While it might seem tempting to make decisions based on intuition, it's crucial to understand the distinct roles of ID and access tokens in the authentication and authorization processes.

What Is an ID Token in Rollup ID?

An ID token is evidence that a user has been authenticated. Introduced by OpenID Connect (OIDC), an open standard for authentication adopted by numerous identity providers, including Rollup ID, the ID token serves as proof of user authentication and looks something like this:

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwOi8vbXktZG9tYWluLmF1dGgwLmNvbSIsInN1YiI6ImF1dGgwfDEyMzQ1NiIsImF1ZCI6IjEyMzRhYmNkZWYiLCJleHAiOjEzMTEyODE5NzAsImlhdCI6MTMxMTI4MDk3MCwibmFtZSI6IkphbmUgRG9lIiwiZ2l2ZW5fbmFtZSI6IkphbmUiLCJmYW1pbHlfbmFtZSI6IkRvZSJ9.bql-jxlG9B_bielkqOnjTY9Di9FillFb6IMQINXoYsw

Encoded as a JSON Web Token (JWT), an ID token allows your application to inspect its content, ensuring it's from the expected issuer and hasn't been altered. The ID token might contain claims about the user, such as their name, email, or other details. However, the primary purpose of the ID token is to prove user authentication.

{
  "iss": "https://passport.rollup.id/",
  "sub": "{identityUrn}",
  "aud": ["{yourClientId}"],
  "exp": 1311281970,
  "iat": 1311280970,
  "name": "Jane Doe",
  "picture": "http://example.com/janedoe/me.jpg",
  "email": "janedoe@example.com"
}

What Is an Access Token in Rollup ID?

An access token, on the other hand, is designed to grant a client application permission to access a specific resource on behalf of the user. Issued by the authorization server after successful user authentication and consent, the access token is used in delegated authorization scenarios. This means a user can authorize a third-party application to perform specific operations on their behalf, with the extent of these operations defined by scopes.

The format of the access token is determined by an agreement between the authorization server and the resource server. In many cases, JWT is a common format for access tokens.

What Shouldn't You Use an ID Token For?

A common mistake is using the ID token to call an API. While the ID token proves user authentication, it's not designed for API authorization. Using the ID token in this manner can expose your application to security risks. For instance, if an attacker steals your ID token, they could potentially use it to access your API as a legitimate client.

What Shouldn't You Use an Access Token For?

The access token is designed to demonstrate authorization to access a resource. It should be used solely for this purpose. Client applications should treat access tokens as opaque strings and not attempt to interpret their content, even if they recognize the format.

In Summary

The distinction between ID and access tokens can be nuanced, but understanding their unique roles is crucial for the security and functionality of your applications. In Rollup ID, the ID token verifies user authentication, while the access token authorizes specific operations on a resource.

By grasping these differences and using tokens appropriately, developers can ensure a secure and seamless experience for users while leveraging the full potential of Rollup ID's authentication and authorization capabilities.

More Articles

View All

Experience the Future of Decentralized Identity with Rollup ID