User Authentication is getting harder for SaaS companies as usage patterns fluctuate and companies scale. It has to work with zero impact on the user experience.
This article covers the main parts of User Authentication: access tokens, ID tokens, refresh tokens, and the authorization code. We also recommend you check out our detailed User Authentication vs Authorization comparison.
What are Access Tokens?
Access Tokens are a core part of User Authentication. These small pieces of code carry data such as usernames, permissions, groups, and time-frames, and servers send them to user devices when needed. For example, the JSON Web Token (JWT) is made up of just three Base64-URL strings.

The Access Token has three main elements:
- Header: The header holds the token’s type and the algorithm used to create it
- Payload: The payload holds user information, including permissions and expirations. Also known as the “claims section”, the payload decides whether the token works, because inadequate or improper permissions block access
- Signature: The signature includes verification data the recipient uses to confirm the token is authentic
The code snippet below contains no personal information except the User ID in the sub claim. However, you can retrieve additional user information by calling the user info API endpoint with the Access Token.
{
"iss": "https://my-domain.frontegg.com/",
"sub": "frontegg|121212",
"aud": [
"https://example.com/fashion-api",
"https://my-domain.frontegg.com/userinfo"
],
"azp": "my_client_id",
"exp": 1311281970,
"iat": 1311280970,
"scope": "openid profile read:models read:admin"
}
Access Token types can vary based on use cases. There’s the User Access Token for when the SaaS app calls on an API to access, write, and modify data. The user needs to approve this token’s usage. Likewise, the App Access Token allows the user to make changes in app settings. There are also Client Tokens that can be embedded into the app as identifiers to access app-levels APIs.
Access Tokens can also be used in Single Sign-On (SSO) flows. Once authorized, the user’s credentials from one SaaS application or service can be used to access other linked apps. The Access Token is stored in the browser.
Related: SSO Solutions: Key Features and Top Vendors
What are Refresh Tokens?
Refresh Tokens are longer-lived credentials that an app exchanges for a new Access Token when the current one expires, so the user doesn’t have to log in again. Besides reducing in-app friction, Refresh Tokens help secure the User Authorization. Single-Page Apps (SPAs) should use the authorization code flow with PKCE instead of the implicit flow, and can use Refresh Tokens if they are rotated or sender-constrained.

The authorization server issues Refresh Tokens to the client. They are then used to obtain new access tokens when the current ones expire. Refresh Tokens also help obtain additional access tokens with narrower scopes.
Refresh Tokens come with the Access Token when used:
{
"access_token": "AYjcyMzY3ZDhiNmJkNTY",
"refresh_token": "RjY2NjM5NzA2OWJjuE7c",
"token_type": "bearer",
"expires": 2400
}
What are ID Tokens?
Identity (ID) Tokens improve performance. They cache user information (profile data) and send it to the client SaaS app, which can use it for many purposes after the user authenticates, improving the user experience. Unlike the Access Tokens above, which are OAuth based, ID Tokens are defined in OpenID Connect (OIDC).
ID Tokens can’t be random strings like Access Tokens. They are all JSON Web Tokens (JWTs) that should never be sent to APIs or used to make User Authorization decisions. ID Tokens are only meant to be read by OAuth clients.

The ID Token contains these claims:
- iss – The issuer of the token
- aud – The audience of the token
- sub – The subject identifier of the end user
- exp – The expiry information of the token
- iat – The time at when the token was created
Here is an example:
{
"iss": "https://my-domain.frontegg.com",
"sub": "frontegg|212121",
"aud": "1111abcabc",
"exp": 1311281980,
"iat": 1311280980,
"name": "Jack Daniels",
"given_name": "Jack",
"family_name": "Daniels"
}
The code above includes identity claims, but use them as seldom as possible: they bloat the token and increase the risk of compromise. Use user info endpoints instead.
What is the Authorization Code?
In SaaS apps with server-side components, the Authorization Code drives the token exchange throughout User Authentication. It lets you keep the authorization server client secret confidential. Without the Authorization Code, you use the Implicit Flow (OAuth 2.0), where you get only the Access Token.
After the user authenticates with the authorization server, the web app’s server-side component manages the session without revealing the server’s response (such as refresh token information or other personal data) to the end-user. This code helps isolate the token from the user client and keep it from being exposed to unauthorized agents.
User Authentication vs User Authorization
Authentication should not be confused with authorization. User Authentication is based on “factors”, which are things that users possess or parameters that they can present to prove their identity.
- Knowledge factors: Factors the user knows, such as access codes, Personal Identification Numbers (PINs), or passwords. Knowledge factors are considered the least secure because attackers can crack them relatively easily.
- Possession factors: Factors the user has, including physical identity documents, keys, hardware access tokens, mobile phones, digital certificates, software tokens, or anything else a user or entity possesses that proves their identity.
- Inherence Factors: Factors related to the user’s identity, such as face images, live video of a user, fingerprint scans, or any other biometric reading. Many consider inherence factors to be the most secure, but sophisticated attackers can compromise them by faking biometric readings.
User Authorization is based on “permissions”, which define what an authenticated user can and cannot do within a SaaS application or service ecosystem.
- Role-Based Permissions: Permissions given to a group of users that share business roles. They specify the resources that this group is allowed to access, supporting the least privilege access principle, which means users are granted the minimal resources they need to perform their business role.
- Device Permissions: Permissions based on the device requesting access. This model can grant different permissions for trusted devices such as corporate laptops or non-trusted devices like personal smartphones or tablets.
- Location permissions: Permissions based on the user’s geo-location. With remote work becoming the norm during the pandemic, authorization systems now use this type of permission to limit access to sensitive resources, support compliance, and reduce the attack surface.
User Authentication with Frontegg
Frontegg is a self-served, PLG-centric User Management platform that covers both Authorization and Authentication for SaaS businesses in one centralized solution. You manage roles and permissions, create strong Authentication flows, and customize your Login Box from one dashboard, without coding and implementing the changes yourself.
Put this into practice with Frontegg
Frontegg is customer identity and access management (CIAM) for B2B SaaS. It's free up to 7,500 monthly active users, including 5 SSO/SCIM connections.
Start for freeThe Complete Guide to SaaS Multi-Tenant Architecture
Read the guide