Невозможно получить всех пользователей из Microsoft Graph с помощью Python SDK.Python

Программы на Python
Anonymous
Невозможно получить всех пользователей из Microsoft Graph с помощью Python SDK.

Сообщение Anonymous »

Мне нужно знать адрес электронной почты и идентификатор пользователя (чтобы я мог идентифицировать пользователя по электронной почте).
Согласно документации Microsoft, приведенный ниже код должен позволять извлечение информации о пользователе.

Код: Выделить всё

import asyncio
import configparser

from azure.identity.aio import ClientSecretCredential
from msgraph import GraphServiceClient
from msgraph.generated.users.item.user_item_request_builder import UserItemRequestBuilder

def main():
# Load settings
config = configparser.ConfigParser()
config.read(['config.cfg', 'config.dev.cfg'])
azure_settings = config['azure']

credentials = ClientSecretCredential(
azure_settings['tenantId'],
azure_settings['clientId'],
azure_settings['clientSecret'],
)
scopes = ['https://graph.microsoft.com/.default']
client = GraphServiceClient(credentials=credentials, scopes=scopes)
query_params = UserItemRequestBuilder.UserItemRequestBuilderGetQueryParameters(select=['id', 'mail', ])

request_config = UserItemRequestBuilder.UserItemRequestBuilderGetRequestConfiguration(query_parameters=query_params)
users = asyncio.run(client.users.get(request_config))
print(users)

Однако я получаю сообщение об ошибке

Код: Выделить всё

Traceback (most recent call last):
File "C:\Users\PycharmProjects\ProcessEmailReceipts\microsoft_graph.py", line 35, in 
main()
File "C:\Users\PycharmProjects\ProcessEmailReceipts\microsoft_graph.py", line 28, in main
request_config = UserItemRequestBuilder.UserItemRequestBuilderGetRequestConfiguration(query_parameters=query_params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: type object 'UserItemRequestBuilder' has no attribute 'UserItemRequestBuilderGetRequestConfiguration'
Глядя на репозиторий, этот класс действительно не существует.
Есть ли способ получить идентификаторы и электронные письма всех пользователей с помощью SDK Python?
Спасибо,

Подробнее здесь: https://stackoverflow.com/questions/783 ... python-sdk

Вернуться в «Python»