microsoftgraph / microsoftgraph/msgraph-beta-sdk-python

sign_ins.get does not support the filter properties from Docs

未关闭
#828 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

status:waiting-for-triage type:bug
主要语言
Python
星标
44
派生
16
平均合并
20 小时 39 分钟
30 天内合并 PR
3

描述

Describe the bug

When attempting to get nonInteractiveUser and servicePrincipal sign-ins, we receive one the following error messages when we try to use the filter properties defined in the Official MSgraph Beta API documentation.

"Invalid filter clause: Could not find a property named 'servicePrincipalId' on type 'microsoft.graph.signIn'."

Invalid filter clause: Could not find a property named 'signInEventTypes' on type 'microsoft.graph.signIn'.", target=None)

Here are some example filters we have tried

filter_query = f"createdDateTime ge {start_time_str} and createdDateTime le {end_time_str} and signInEventTypes/any(t: t eq 'nonInteractiveUser' or t eq 'servicePrincipal')"

filter_query = "signInEventTypes/any(t: t eq 'nonInteractiveUser' or t eq 'servicePrincipal')"

filter_query = f"servicePrincipalId eq '{id}'"

Notes:

  1. This exact same code works fine via the Python Beta SDK if we only include the createdDateTime properties in the filter
  2. This exact same filter (including signInEventTypes/any property) works fine when used via the MSGraph Beta API over HTTP

Questions

  1. I understand this is a beta, but should we expect the Python SDK to behave differently from the Beta Docs and the Beta HTTP API?
Expected behavior
  1. The python beta SDK would support the same filter properties as documented in the MSGraph Beta API documentation
  2. The python beta SDK would support the same filter properties as the MSGraph Beta HTTP API
How to reproduce
import asyncio
import os

from azure.identity import InteractiveBrowserCredential
from kiota_abstractions.base_request_configuration import RequestConfiguration
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.audit_logs.sign_ins.sign_ins_request_builder import (
    SignInsRequestBuilder,
)

AZURE_TENANT_ID = os.environ.get("AZURE_TENANT_ID")
CERT = os.environ.get("CERT_PATH")


async def get_sign_ins(client):
    """Get sign-ins with SDK"""

    filter_query = (
        "signInEventTypes/any(t: t eq 'nonInteractiveUser' or t eq 'servicePrincipal')"
    )

    query_params = SignInsRequestBuilder.SignInsRequestBuilderGetQueryParameters(
        filter=filter_query,
        top=1,
    )

    request_configuration = RequestConfiguration(
        query_parameters=query_params,
    )
    result = await client.audit_logs.sign_ins.get(
        request_configuration=request_configuration
    )

    return result.value


async def main():
    """Main async function to process sign-ins"""

    credential = InteractiveBrowserCredential(
        tenant_id=AZURE_TENANT_ID, connection_verify=CERT
    )
    client = GraphServiceClient(
        credential,
        scopes=["https://graph.microsoft.com/.default"],
    )
    result = await get_sign_ins(client)
    print(result)


if __name__ == "__main__":
    asyncio.run(main())

SDK Version

1.31.0

Latest version known to work for scenario above?

No response

Known Workarounds

Use HTTP to hit beta API via python requests library

Debug output

"Invalid filter clause: Could not find a property named 'signInEventTypes' on type 'microsoft.graph.signIn'."

Configuration
  • OS: macOS Sequoia 15.3.1
  • Architecture: M1 ARM
Other information

No response

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 SignInsRequestBuilder 使用的生成入口 audit_logs/sign_ins/sign_ins_request_builder.py 开始,检查 get request 如何构建其筛选查询。使用复现筛选条件,将 SDK request 与文档中的 beta HTTP request 进行比较。当 signInEventTypes 和 servicePrincipalId 筛选条件可通过 Python SDK 接受时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
api
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。