Error "invalid_client" when trying to get a token from Microsoft API

7.2k views Asked by At

I'm trying to develop a drive solution (Onedrive) in a windev program.

I created an application in Microsoft Azure and created a secret key.

enter image description here

enter image description here

When doing the first request https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope} &response_type=code&redirect_uri={redirect_uri} I'm redirected on the connection page.

Once I'm connected I get a code back as https://login.live.com/oauth20_authorize.srf?code={code}.

But when I ask for a token posting this request : POST https://login.live.com/oauth20_token.srf Content-Type: application/x-www-form-urlencoded client_id={client_id}&redirect_uri={redirect_uri}&client_secret={client_secret} &code={code}&grant_type=authorization_code

I get this back

{ "error":"invalid_client", "error_description":"The client does not exist or is not enabled for consumers. If you are the application developer, configure a new application through the App Registrations in the Azure Portal at https:\/\/go.microsoft.com\/fwlink\/?linkid=2083908.", "correlation_id":"471e800c-69b4-43c6-a03f-a1f7e9512e6b" }

Thank you for your help.

1

There are 1 answers

12
Carl Zhao On BEST ANSWER

This error means you are using a Microsoft Account to login your client app, but it is not enabled for that.

To change the setting for an existing AD App, navigate to the Manifest blade of it in the portal, find the signInAudience attribute, set it with AzureADandPersonalMicrosoftAccount or PersonalMicrosoftAccount.

enter image description here