Reputation: 3411
I followed this tutorial to generate an access token from client app for target app. According to the comment for this tutorial, for the resources
, I changed to App ID URL. But I am still not able to successfully generate bearer token for the target app.
It shows this error message:
AdalException: {"error":"invalid_request","error_description":"AADSTS90002: Tenant '' not found. This may happen if there are no active subscriptions for the tenant....}
Anyone knows what else I missed?
Upvotes: 6
Views: 29964
Reputation: 218
In my case I mistakened the client Id (a string that looks like xxxxx-xxx-xxxx-xxxx-xxxxxxx
) with the tenant Id (a string that looks like myproject.onmicrosoft.com
)
Upvotes: 1
Reputation: 123
For me the issue was resolved by using older version of Microsoft.IdentityModel.Clients.ActiveDirectory. I had to used 3.13.8 version. Latest version has issues.
Upvotes: 10
Reputation: 27578
Using ADAL to get access token using client credential flow :
AuthenticationContext authenticationContext =
new AuthenticationContext("https://login.microsoftonline.com/<tenantId>");
ClientCredential clientCredential = new ClientCredential(clientId, appKey);
AuthenticationResult result =
await authenticationContext.AcquireTokenAsync("https://resourceUrl",
clientCredential);
Reference : https://github.com/AzureAD/azure-activedirectory-library-for-dotnet/wiki/Client-credential-flows
And document : Service to service calls using client credentials
Upvotes: 5