Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Graph API: Getting error "Authorization_IdentityNotFound"

With my outlook.com account I logged in to portal.azure.com and I created a new application. Microsoft has provided a sample app (daemon_console) for quick experiments (in QuickStart guide) and I followed steps provided for the sample app, the app automatically takes the application id and client secret you generated and updates the configuration JSON file (appsettings.json) with this info. I downloaded the code after these steps but when I run the sample app it throws the error "Authorization_IdentityNotFound".

Looks like it is able to fetch the token but following code is throwing the error:

            var httpClient = new HttpClient();
            var apiCaller = new ProtectedApiCallHelper(httpClient);
            await apiCaller.CallWebApiAndProcessResultASync($"{config.ApiUrl}v1.0/users", result.AccessToken, Display);

Microsofts page has step to get Admin consent in two ways:

  • If you are a global administrator, go to API Permissions page select Grant admin consent for Enter_the_Tenant_Name_Here
  • Standard user If you're a standard user of your tenant, then you need to ask a global administrator to grant admin consent for your application. To do this, give the following URL to your administrator: https://login.microsoftonline.com/common/adminconsent?client_id=my apps client id

I have tried both these options. With the first option, I am able to grant the required permissions. But the issue still exists.

With the second option when I go to the suggested URL it fails with error: "AADSTS500113: No reply address is registered for the application."

I think this should have been a straightforward process but somehow the app is not able to execute and fails with errors:

 "code": "Authorization_IdentityNotFound",
"message": "The identity of the calling application could not be established.",

Please let me know if anyone has tried these steps and has managed to resolve this issue.

Note that I can run "https://graph.microsoft.com/v1.0/users" from graph explorer with my outlook.com account and it works perfectly fine.

like image 685
user13260866 Avatar asked Sep 26 '26 21:09

user13260866


1 Answers

I tested it, and at first I was running into the same issue, its because of the common in the appsettings.json

replace the   "Tenant": "common" 
with   "Tenant": "your Tenant ID",

You can get the tenant ID from the overview page of your app registration Directory (tenant) ID. After you do that, make sure you right click the project and click rebuild. because if I just do a normal run it had it cached and did not update it from common.

like image 168
alphaz18 Avatar answered Sep 28 '26 10:09

alphaz18



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!