Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure active directory 如何在没有用户的情况下获得访问权限_Azure Active Directory_Office365_Microsoft Graph Api_Token - Fatal编程技术网

Azure active directory 如何在没有用户的情况下获得访问权限

Azure active directory 如何在没有用户的情况下获得访问权限,azure-active-directory,office365,microsoft-graph-api,token,Azure Active Directory,Office365,Microsoft Graph Api,Token,我正在尝试按照此操作获取访问令牌。我正在使用API请求获取访问令牌/oauth2/token。当我对上述给定链接使用步骤5时,我得到以下错误: { "error": { "code": "InvalidAuthenticationToken", "message": "Access token validation failure. Invalid audience.", "innerError": { "request-id": "e9e9820e-2a3f-411a-bc77-760c9

我正在尝试按照此操作获取访问令牌。我正在使用API请求获取访问令牌/oauth2/token。当我对上述给定链接使用步骤5时,我得到以下错误:

{
"error": {
"code": "InvalidAuthenticationToken",
"message": "Access token validation failure. Invalid audience.",
"innerError": {
  "request-id": "e9e9820e-2a3f-411a-bc77-760c9369fc8f",
  "date": "2020-01-02T06:17:41"
}
}
}
我已使用以下权限注册应用程序:Calendars.Read、Calendars.ReadWrite、Sites.Read.All、User.Read、User.Read.All,并已生成密钥并将重定向url注册为: User.Read.All

我的问题是: 1.我在创建应用程序时有没有做错什么? 2.为什么第4步不起作用的链接?
3.我是否使用上述给定的api请求获得了错误的访问权限?

在步骤5中,它调用Microsoft Graph-,因此请确保您的应用程序具有
用户。读取。Microsoft Graph中的所有
应用程序权限(必须是
应用程序
权限,而不是
委派的
权限),添加权限后,显示如下所示(注意:别忘了单击授予管理员同意按钮)

在您提供的文档中,它使用v2.0端点
/oauth2/v2.0/token
,但您在问题中使用v1.0端点
/oauth2/token

因此,请将请求URL更改为
/oauth2/v2.0/token
,然后使用下面的URL

请求URL:

POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
请求机构:

client_id=xxxxxxxxxxxxxxx
&scope=https://graph.microsoft.com/.default
&client_secret=xxxxxxxxxxxxxxxx
&grant_type=client_credentials
你可以在商店里买到代币

然后使用令牌调用API:

GEThttps://graph.microsoft.com/v1.0/users/

在步骤5中,它调用Microsoft Graph-,因此请确保您的应用程序具有Microsoft Graph中的
用户.Read.All
应用程序权限(必须是
应用程序
权限,而不是
委派的
权限),添加权限后,显示如下所示(注意:别忘了单击授予管理员同意按钮)

在您提供的文档中,它使用v2.0端点
/oauth2/v2.0/token
,但您在问题中使用v1.0端点
/oauth2/token

因此,请将请求URL更改为
/oauth2/v2.0/token
,然后使用下面的URL

请求URL:

POST https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token
请求机构:

client_id=xxxxxxxxxxxxxxx
&scope=https://graph.microsoft.com/.default
&client_secret=xxxxxxxxxxxxxxxx
&grant_type=client_credentials
你可以在商店里买到代币

然后使用令牌调用API:

GEThttps://graph.microsoft.com/v1.0/users/