Either SCP or Roles Claim need to be present in the token Error in Microsoft Graph API

Fixed: โ€œEither scp or roles claim need to be present in the tokenโ€ Error in Microsoft Graph API

No comments

Loading

In this blog post, we will learn how to fix the โ€œEither scp or roles claim need to be present in the tokenโ€ error in Microsoft Graph API Authentication. While you are testing the Graph API endpoint from the Postman tool or Copilot Studio or from your application, you will get the below error:

When integrating Microsoft Graph API with Azure AD authentication, many developers encounter the error:

For example, I have called the below Graph API endpoint from my Postman tool. Though the token ID is valid, I got the below-mentioned error.

Graph API Endpoint: https://graph.microsoft.com/v1.0/sites/{SITEID}/Drives
{
"error": {
"code": "AccessDenied",
"message": "Either scp or roles claim need to be present in the token.",
"innerError": {
"date": "2025-02-28T04:41:38",
"request-id": "0d03df1e-365c-4d7f-bc4f-34d4b51c1ac4",
"client-request-id": "0d03df1e-365c-4d7f-bc4f-34d4b51c1ac4"
}
}
}

Access denied - Either scp or roles claim need to be present in the token
Access denied โ€“ Either scp or roles claim need to be present in the token

This error typically occurs when the access token does not contain the necessary permissions (scp for delegated permissions or roles for application permissions).

In this article, we will cover:

  • What causes this error?
  • How to fix it step by step
  • Best practices for obtaining the correct access token

This guide applies to scenarios where you need to authenticate Microsoft Graph API using Azure AD OAuth 2.0 token for Copilot Studio, Power Automate, or Postman API testing.

What Causes the โ€œscp or roles claimโ€ Error?

Microsoft Graph API expects one of the following claims in the JWT access token:

  • scp (Scope Claim): Used in delegated authentication, meaning a signed-in user is making the request.
  • roles (Roles Claim): Used in application authentication, meaning a background process or app (without user interaction) is making the request.

ย If neither claim is present, the request is denied.

Available Fixes in Google:ย  Step-by-Step Guide to Fix the Issue

If you search with this error in google, you will get the following fixes.

Step 1: Verify Your Token in jwt.ms

Before troubleshooting, check if your access token contains the correct claims.

1๏ธโƒฃ Go to jwt.ms
2๏ธโƒฃ Paste your access token
3๏ธโƒฃ Look for either the scp or roles claim under "payload"

  • If scp is missing, your app lacks delegated permissions.
  • If roles is missing, your app lacks application permissions.

Step 2: Ensure Correct API Permissions in Azure AD

To fix missing claims, you need to assign the correct API permissions in Azure App Registration.

โžก๏ธ If using Delegated Authentication (User-Based Requests)

1๏ธโƒฃ Go to Azure Portal โ†’ Azure Active Directory
2๏ธโƒฃ Select App Registrations โ†’ Your App
3๏ธโƒฃ Click API Permissions โ†’ Add a permission
4๏ธโƒฃ Select Microsoft Graph โ†’ Delegated Permissions
5๏ธโƒฃ Add required permissions such as:

  • Sites.Read.All
  • Sites.Manage.All
  • Sites.FullControl.All
    6๏ธโƒฃ Click Grant Admin Consent

โžก๏ธ If using Application Authentication (App-Only Requests)

1๏ธโƒฃ Go to Azure Portal โ†’ Azure Active Directory
2๏ธโƒฃ Select App Registrations โ†’ Your App
3๏ธโƒฃ Click API Permissions โ†’ Add a permission
4๏ธโƒฃ Select Microsoft Graph โ†’ Application Permissions
5๏ธโƒฃ Add required permissions such as:

  • Sites.Read.All
  • Sites.Manage.All
  • Sites.FullControl.All
    6๏ธโƒฃ Click Grant Admin Consent

Important: Delegated permissions require a signed-in user, whereas application permissions do not.

Step 3: Request Access Token with Correct Scope

Once permissions are set, you need to obtain a valid OAuth 2.0 access token.

Delegated Authentication (User-Based Requests)

Use the following request in Postman or Power Automate to get an access token:

POST https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded

client_id={client_id}
client_secret={client_secret}
grant_type=authorization_code
scope=https://graph.microsoft.com/.default

The scope parameter ensures the token includes scp.

Application Authentication (App-Only Requests)

Use the following request to get an app-only access token:

POST https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded

client_id={client_id}
client_secret={client_secret}
grant_type=client_credentials
scope=https://graph.microsoft.com/.default

The scope parameter ensures the token includes roles.

Actual Fixes Based on Personal Experience

Whatever the fixes you apply from the above steps, your issue will not go away, straight way you need to change the below Graph API permission type from โ€œDelegatedโ€ to โ€œApplicationโ€, until a few months back it was working with the delegated permission type but with the Microsoft latest updates, this is not working any more while call your API and generate token code, it has to be changed to application type, then your same API will start working either from Postman or Copilot or Power Automate or any other applications.

API Permissions in Azure App Registration
API Permissions in Azure App Registration

Now, I have removed the delegated type Graph API permissions and added them to the application permissions type, then granted admin consent.

Follow this navigation to create Graph permission with the application type:

Click on the โ€œ+ Add a permissionโ€ link. Click on the Microsoft Graph API link. Then for this question: What type of permissions does your application require?

Click on the โ€œApplication Permissions.โ€.

What type of permissions does your application require in Azure
What type of permissions does your application require in Azure

Then, select your needed permissions. For example, I have selected the below permissions:

  • Sites.Read.All
  • User.Read.All

Then, grant admin consent; finally, your Graph API permissions should look like below:

Azure Graph API permissions with Application Type
Azure Graph API permissions with Application Type

Now, go to your Postman tool, create a new access token, and execute the same endpoint where you were getting the โ€œEither scp or roles claim needs to be present in the tokenโ€ error. This time, you will not get any more errors, as you can see I got the response โ€œ200 OK.โ€.

Either scp or roles claim need to be present in the token issue fixed
Either scp or roles claim need to be present in the token issue fixed

Let us understand what is delegated API permission type and application permission types.

Request API Permissions Types: Delegated vs. Application

In Azure App Registrations, when adding API permissions for Microsoft Graph API (or other APIs), you are asked:

โ€œWhat type of permissions does your application require?โ€œ

This presents two options:
โœ… Delegated Permissions
โœ… Application Permissions

Letโ€™s understand the difference between them and when to use each.

1๏ธโƒฃ Delegated Permissions (User-Based Access)

Definition:

  • Delegated permissions are used when an application acts on behalf of a signed-in user.
  • The app inherits the userโ€™s permissions and cannot access resources beyond what the user is allowed to access.

Example Use Cases:

  • A Copilot Studio bot that fetches SharePoint files for a signed-in user.
  • A Power Automate flow that retrieves a userโ€™s emails from Outlook.
  • A web application that allows users to sign in and view their Microsoft 365 calendar.

How It Works:

  • The user signs in to Azure AD.
  • The app requests an access token on behalf of the user.
  • The access token includes an scp (scope) claim with the allowed actions.

Example of an Access Token Claim for Delegated Permissions:

{
"scp": "User.Read Files.Read.All"
}

Here, User.Read and Files.Read.All mean the app can read user profile and OneDrive files based on the userโ€™s access level.

Key Point: The app can only perform actions that the signed-in user has permission for.

2๏ธโƒฃ Application Permissions (App-Only Access)

Definition:

  • Application permissions are used when an app runs without a signed-in user.
  • The app gets full access to resources (such as SharePoint, Teams, or OneDrive) without requiring user login.

Example Use Cases:

  • A background service that syncs data between SharePoint and an external database.
  • A Power Automate scheduled flow that automatically exports SharePoint files.
  • A reporting tool that pulls all usersโ€™ Microsoft 365 usage analytics.

How It Works:

  • The app authenticates using client credentials (client ID + client secret or certificate).
  • The access token includes a roles claim instead of scp.

Example of an Access Token Claim for Application Permissions:

{
"roles": ["Sites.Read.All", "Mail.ReadWrite.All"]
}

Here, Sites.Read.All allows the app to read all SharePoint sites, and Mail.ReadWrite.All allows full access to all mailboxes.

Key Point: The app acts as a fully privileged background process, not as a user.

Comparison Table: Delegated vs. Application Permissions

Feature Delegated Permissions Application Permissions
Requires User Sign-In? โœ… Yes โŒ No
Acts on Behalf of User? โœ… Yes โŒ No
Has Full Admin Access? โŒ No (limited by user permissions) โœ… Yes (granted by admin)
Used in Copilot Studio? โœ… Yes โŒ No
Used in Power Automate? โœ… Yes (manual flows) โœ… Yes (background flows)
Use Case Example A user fetching their SharePoint files A background process scanning all SharePoint sites
Token Contains? scp (scopes claim) roles (roles claim)
Requires Admin Consent? โœ… Sometimes โœ… Always

When to Choose Delegated vs. Application Permissions?

โœ… Use Delegated Permissions When:

  • Your app requires a signed-in user.
  • You want to limit access to what the user has access to.
  • Example: A Copilot Studio bot retrieving a SharePoint file for a logged-in user.

โœ… Use Application Permissions When:

  • Your app runs in the background without user interaction.
  • You need to access all resources, not just what a specific user can access.
  • Example: A Power Automate flow that reads all SharePoint sites to generate a report.

How to Add API Permissions in Azure App Registration?

1๏ธโƒฃ Go to Azure Portal โ†’ Azure Active Directory
2๏ธโƒฃ Click App Registrations โ†’ Select Your App
3๏ธโƒฃ Click API Permissions โ†’ Add a Permission
4๏ธโƒฃ Select Microsoft Graph (or another API like SharePoint)
5๏ธโƒฃ Choose either:

  • Delegated Permissions โ†’ Select the needed permissions
  • Application Permissions โ†’ Select the needed permissions
    6๏ธโƒฃ Click Grant Admin Consent (Required for Application Permissions)

โœ… Done! Your app now has the correct API permissions.

Final Thoughts โ€“ Delegated Permissions or Application Permissions?

  • Delegated Permissions = Used for apps that act on behalf of a user.
  • Application Permissions = Used for background apps that run without a user.
  • Admin consent is required for application permissions and some delegated permissions.

Understanding the difference is key to successfully integrating Microsoft Graph API, Power Automate, and Copilot Studio!

Conclusion

Thus, in this article, we have learned how to fix the 403 forbidden access denied error or โ€œEither scp or roles claim need to be present in the token.โ€ in Azure App registration and the Postman tool.

The "Either scp or roles claim need to be present in the token" error is common when working with Microsoft Graph API in Copilot Studio, Power Automate, or Azure App Services.

โœ… Summary of Fixes:

1๏ธโƒฃ Decode the token using jwt.ms and check scp or roles.
2๏ธโƒฃ Add correct API permissions in Azure AD and grant admin consent.
3๏ธโƒฃ Use the correct OAuth flow (Delegated vs Application).
4๏ธโƒฃ Validate the token and test API calls using Postman or Graph Explorer.

By following these steps, you can successfully authenticate and call Microsoft Graph API without permission errors.

Have questions or need help? Drop a comment below!

YouTube Video Demo:

ย 

About Post Author


Discover more from Global SharePoint

Subscribe to get the latest posts sent to your email.

Do you have a better solution or question on this topic? Please leave a comment