Microsoft Entra ID
Formerly Azure Active Directory
Last updated
Was this helpful?
Formerly Azure Active Directory
Last updated
Was this helpful?
By default, Entra ID issues opaque Access Tokens, which can only be validated by your backend via the Microsoft Graph API.
To enable validation of access tokens in a non-vendor-locked way—such as demonstrated in the Web API section—you need to configure a custom scope.
Go to Microsoft Azure Portal.
In the left panel, select "Microsoft Entra ID".
Navigate to "Manage > App Registrations".
Click "New Registration".
Enter "My App - API" as the name, then click Register.
Set Supported Account Type to Accounts in this organization.
In the left menu, go to "Manage > Expose API".
Click "Add a scope".
Configure as follows, then click "Add Scope":
Application ID URI: api://my-app-api
(then save and continue)
Scope name: access_as_user
Who can consent: Admins and Users
Admin Consent Display Name: "JWT Access Token"
Admin Consent Description: "Ensure issuance of a JWT Access Token"
User Consent Display Name: "View your basic profile"
User Consent Description: "Allows the app to see your basic profile (e.g., name, picture, user name, email address)"
State: Enabled
To validate the token on the backend, ensure that the aud
claim in the JWT access token matches api://my-app-api
. For more details, refer to the Web API documentation.
Go to Microsoft Azure Portal.
In the left panel, select "Microsoft Entra ID".
Navigate to "Manage > App Registrations".
Click "New Registration".
Enter "My App" as the display name (replace with your actual app name).
Set Supported Account Type to Accounts in this organization.
Click Register.
Click "Add a Redirect URI".
Click "Add Platform" > "Single-Page Application".
Set Redirect URIs:
Production: https://my-app.com/
(include trailing slash; adjust if hosted under a subpath, e.g., https://my-app.com/dashboard/
)
Local Development: http://localhost:5173/
(include trailing slash; adjust based on your dev server)
Ensure "Access Token" and "ID Token" are checked.
Click Save.
In the left panel, go to "API Permissions".
Click "Add a permission".
Click "APIs My Organization Uses".
Select "My App - API".
Check "access_as_user", then click "Add permission".
In the left panel, click "Overview" and copy:
Application (client) ID
Directory (tenant) ID
These are required to configure oidc-spa
.
oidc-spa
To test your configuration using oidc-spa
: