|
| 1 | +--- |
| 2 | +title: The identity of the calling application could not be established |
| 3 | +description: Provides a solution to the error "The identity of the calling application could not be established" when using Microsoft Graph. |
| 4 | +ms.date: 03/28/2025 |
| 5 | +ms.service: entra-id |
| 6 | +ms.custom: sap:Getting access denied errors (Authorization) |
| 7 | +ms.reviewer: willfid, v-weizhu |
| 8 | +--- |
| 9 | +# Error "The identity of the calling application could not be established" |
| 10 | + |
| 11 | +This article provides a solution to the error message "The identity of the calling application could not be established" when using Microsoft Graph. |
| 12 | + |
| 13 | +## Symptoms |
| 14 | + |
| 15 | +When using Microsoft Graph or some services that rely on it, you encounter the following error message: |
| 16 | + |
| 17 | +> The identity of the calling application could not be established |
| 18 | +
|
| 19 | +## Cause |
| 20 | + |
| 21 | +This error occurs because the `oid` and `sub` claims are missing from the access token. The root cause is that the service principal doesn't exist in the tenant or the tenant isn't aware of the application. |
| 22 | + |
| 23 | +## Solution for Partner scenario |
| 24 | + |
| 25 | +If the application is a Partner application, ensure that you complete the Partner pre-consent process. For more information, see [Partner pre-consent](https://github.com/microsoft/Partner-Center-Explorer/blob/master/docs/Preconsent.md) and add your application or service principal to the AdminAgents group. |
| 26 | + |
| 27 | +Here's an updated PowerShell script for using Microsoft Graph: |
| 28 | + |
| 29 | +```powershell |
| 30 | +Connect-MgGraph |
| 31 | +
|
| 32 | +$AppId = '<Application ID>' |
| 33 | +
|
| 34 | +$g = Get-MgGroup -All -Filter "displayName eq 'AdminAgents'" |
| 35 | +
|
| 36 | +$s = Get-MgServicePrincipal -All -Filter "appId eq '$AppId'" |
| 37 | +
|
| 38 | +$params = @{ |
| 39 | + "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/$($s.id)" |
| 40 | +} |
| 41 | +
|
| 42 | +New-MgGroupMemberByRef -GroupId $g.id -BodyParameter $params |
| 43 | +``` |
| 44 | + |
| 45 | +Ensure that you replace `<Application ID>` with your application's actual Application ID. |
| 46 | + |
| 47 | +## Solution for Non-Partner scenario |
| 48 | + |
| 49 | +If this isn't a Partner application, add the service principal to the tenant and consent to the permissions required by the application. |
| 50 | + |
| 51 | +You can [build an admin consent URL](/entra/identity/enterprise-apps/grant-admin-consent?pivots=portal#construct-the-url-for-granting-tenant-wide-admin-consent) like the following one: |
| 52 | + |
| 53 | +`https://login.microsoftonline.com/{organization}/adminconsent?client_id={client-id}` |
| 54 | + |
| 55 | +Then, sign in with a Global Administrator account of the tenant where you are trying to access resources. |
| 56 | + |
| 57 | +[!INCLUDE [Azure Help Support](../../../includes/azure-help-support.md)] |
0 commit comments