首页 > 解决方案 > 尝试从 Microsoft API 获取令牌时出现错误“invalid_client”

问题描述

我正在尝试在windev程序中开发驱动解决方案(Onedrive)。

我在 Microsoft Azure 中创建了一个应用程序并创建了一个密钥。

在此处输入图像描述

在此处输入图像描述

在执行第一个请求时https://login.live.com/oauth20_authorize.srf?client_id={client_id}&scope={scope} &response_type=code&redirect_uri={redirect_uri},我在连接页面上被重定向。

连接后,我会返回一个代码https://login.live.com/oauth20_authorize.srf?code={code}.

但是,当我要求发布此请求的令牌时: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

我把这个拿回来

{ "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" }

感谢您的帮助。

标签: azure-active-directorymicrosoft-graph-apionedrivewindev

解决方案


此错误表示您正在使用 Microsoft 帐户登录您的客户端应用程序,但未为此启用它。

要更改现有 AD 应用程序的设置,请导航到门户中它的Manifest刀片,找到signInAudience属性,使用AzureADandPersonalMicrosoftAccount或进行设置PersonalMicrosoftAccount

在此处输入图像描述


推荐阅读