简体   繁体   English

Azure AD 验证与 python

[英]Azure AD validation with python

I have some difficulties understanding the Graph API documentation.我在理解 Graph API 文档时遇到了一些困难。 I want to check with an in-house application if a user is currently signed in.如果用户当前已登录,我想检查内部应用程序。

The app has the following permissions: - Application: Read directory data - Delegated: Read directory data - Delegated: Read all groups - Delegated: Sign in and read user profile该应用程序具有以下权限: - 应用程序:读取目录数据 - 委托:读取目录数据 - 委托:读取所有组 - 委托:登录并读取用户配置文件

The token is obtained at https://login.microsoftonline.com/ {directoryId}/oauth2/token Here is the situation:令牌是在https://login.microsoftonline.com/ {directoryId}/oauth2/token 获得的,情况如下:

Theory理论

The documentation says to GET /auditLogs/signIns/{id} ( https://docs.microsoft.com/en-us/graph/api/signin-get )文档说 GET /auditLogs/signIns/{id} ( https://docs.microsoft.com/en-us/graph/api/signin-get )

and gives as example: https://graph.microsoft.com/v1.0/auditLogs/signIns/ {id} ( https://docs.microsoft.com/en-us/graph/api/signin-get?view=graph-rest-1.0&viewFallbackFrom=graph-rest-1.6#tabpanel_CeZOj-G++Q_http )并举例说明: https://graph.microsoft.com/v1.0/auditLogs/signIns/ {id} ( https://docs.microsoft.com/en-us/graph/api/signin-get?view =graph-rest-1.0&viewFallbackFrom=graph-rest-1.6#tabpanel_CeZOj-G++Q_http )

But the working API request we are using look like https://graph.windows.net/ {directoryId}/...但是我们正在使用的工作 API 请求看起来像https://graph.windows.net/ {directoryId}/...

Problem问题

When I request https://graph.windows.net/ {directoryId}/auditLogs/signIns/{objectIdOfUser} I get [Request_ResourceNotFound] "Resource not found for the segment 'auditLogs'."当我请求https://graph.windows.net/ {directoryId}/auditLogs/signIns/{objectIdOfUser} 时,我得到 [Request_ResourceNotFound]“未找到段 'auditLogs' 的资源。”

When I request (as the documentation suggests) https://graph.windows.net/auditLogs/signIns/ {objectIdOfUser} I get [Request_BadRequest] "Invalid domain name in the request url."当我请求(如文档所示) https://graph.windows.net/auditLogs/signIns/ {objectIdOfUser} 我得到 [Request_BadRequest]“请求 url 中的无效域名”。

When I request (as the documentation example suggests) https://graph.microsoft.com/v1.0/auditLogs/signIns/ {id} I get [InvalidAuthenticationToken] "Access token validation failure. Invalid audience."当我请求(如文档示例所示) https://graph.microsoft.com/v1.0/auditLogs/signIns/ {id} 我得到 [InvalidAuthenticationToken] “访问令牌验证失败。无效的受众。”

Can you provide us with a working example (with plain URLs) of how obtaining the 'signinStatus' ressource for the ''objectId' a given user?您能否为我们提供一个工作示例(带有纯 URL),说明如何为给定用户获取“objectId”的“signinStatus”资源?

Sounds like you have gotten a token for Azure AD Graph API, which is not the same as Microsoft Graph API.听起来您已经获得了 Azure AD Graph API 的令牌,这与 Microsoft Graph API 不同。

Make sure you request the token with resource https://graph.microsoft.com .确保使用资源https://graph.microsoft.com请求令牌。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM