oAuth2-AADSTS90009:连接Azure Active Directory时出现问题

时间:2018-10-22 06:20:47

标签: azure azure-active-directory

连接到Azure Active Directory时出现错误消息

“ AADSTS90009:应用程序'xxxxxxxxxxxxxxxxx'正在为其自身请求令牌。仅当使用基于GUID的应用程序标识符指定资源时,才支持此方案。

3 个答案:

答案 0 :(得分:0)

此错误表示您在resource参数中提供的字段正在为其自身请求令牌。

或者,您可以提供已注册的Web API或其他资源的应用程序ID URI,并提供范围以获取该资源(Microsoft Graph,Office API等)的令牌。

答案 1 :(得分:0)

如果要使用Web应用程序调用Web API,请参阅sample。详细步骤。

  1. 在Azure门户中注册Web API应用程序。有关更多详细信息,请参阅document
  2. 在Azure Portal中注册Web应用程序
  3. 授予权限。(将Web API应用程序添加到Web应用程序应用程序中)

    a。选择您的Web应用程序
    b。设置权限。    enter image description here    enter image description here    enter image description here    enter image description here

  4. 获取访问令牌

    方法:POST

    URL:https://login.microsoftonline.com/ [目录ID] / oauth2 /令牌

    标题

    缓存控制:无缓存 内容类型:application / x-www-form-urlencoded

    身体

    grant_type:密码 resource:您的应用ID URI client_id:[应用程序ID] client_secret:[键值] 用户名:[帐户名] 密码:[密码]

答案 2 :(得分:0)

错误信息表明您正在使用Azure AD应用程序URL作为资源。

正如我们提到的,您需要使用要作为资源访问的WebApp API(不是Azure AD应用程序)。有关更多信息,请参阅此link

POST https://login.microsoftonline.com/{tenantId}/oauth2/token 

Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials&client_id={clientId}&client_secret={secret key}=&resource={resourceaddress}

enter image description here

注意::如果要使用OAuth 2 grant type: password,则需要注册Azure AD 本机应用程序。有关更多信息,请参阅其他SO thread