Why does AcquireToken with ClientCredential fail with invalid_client (ACS50012)?

这一生的挚爱 提交于 2019-12-03 12:22:15

This turned out to be an error in Windows Azure, there was nothing wrong with my code or config.

After Microsoft fixed the problem in Azure, I had to create a new application and it started working.

Forum answer from Microsoft:

Hi,

We are seeing some errors with applications created in a several day time range, ending yesterday. We are continuing to fix up these applications but I don't have a good eta when this will be done. I'm apologize for the impact here.

Can you try creating a new application and retying the operation with the new client id?

thanks

Have a look at this link: https://azure.microsoft.com/en-gb/documentation/articles/resource-manager-net-sdk/

The latest version of Active Directory Authentication Library does not support AcquireToken method, instead you have to use AcquireTokenAsync method.

var result = await authenticationContext.AcquireTokenAsync(resource: "https://{domain}.onmicrosoft.com/{site-if applicable}", clientCredential: credential);

I was having the same issue but only running the code directly from Azure (inside an Azure Website).

I solved upgrading 'Microsoft.IdentityModel.Clients.ActiveDirectory' package to '2.6.1-alpha'

The azure version of the translator has changed things once more- the Oauth token request uses a new url and only needs your secret key, instead of all the other baggage. This page discusses it (but using PHP code): http://www.bradymoritz.com/php-code-for-bingmicrosoftazure-translator/

The key items are:

  1. Post an empty request to https://api.cognitive.microsoft.com/sts/v1.0/issueToken
  2. Pass it your secret key using the header "Ocp-Apim-Subscription-Key: "
  3. Or, just use the querystring parameter: "Subscription-Key="

Then get the body of the return as the actual token- it's the whole body, not in json format.

This is a lot simpler than the method used before, but it'd definitely a pain that things have yet again changed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!