0
votes

I 'm having the below code

string aadInstance = "https://login.windows.net/{0}";
string tenant = "<tenant>.onmicrosoft.com";
string clientId = "d22d1d2a-...";
Uri redirectUri = new Uri("http://redirect");

string authority = String.Format(aadInstance, tenant);
string apiResourceId = "https://<resource>.onmicrosoft.com/sample";
string apiBaseAddress = "http://localhost:9003/";

AuthenticationContext authContext = authContext = new AuthenticationContext(authority);
AuthenticationResult authResult = authContext.AcquireToken(apiResourceId, clientId, redirectUri);

I have added the application as native application in active directory and I 'm getting the error. "AADSTS50001: The application named .onmicrosoft.com/sample">https://.onmicrosoft.com/sample was not found in the tenant named .onmicrosoft.com. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant."

I 'm confused about what should be apiresource id, if possible please give me the snapshots of how to configure the application both in native and web api application, where should be the resource id and tenant id names and so on, I 'm also confused about "Permissions to other application" where in I ' m searching for "avocado" which is not visible.

1

1 Answers

0
votes

Based on the error message, it seems that you were using the incorrect resource when you were requesting the access token.

The resource should be the APP ID URI which web API the native app consumes, you can find it through the old portal like figure below: enter image description here

We can also find it on the new portal via Azure Active Directory->App registrations->{You app}->Properties:

enter image description here