An API that connects multiple Microsoft services, enabling data access and automation across platforms
I have a new error : DeviceCodeCredential.get_token failed: Authentication failed: AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'.
import asyncio
from msgraph import GraphServiceClient
from msgraph.generated.models.chat import Chat
from msgraph.generated.models.chat_type import ChatType
from msgraph.generated.models.conversation_member import ConversationMember
from msgraph.generated.models.aad_user_conversation_member import AadUserConversationMember
from azure.identity import DeviceCodeCredential
# Multi-tenant apps can use "common",
# single-tenant apps must use the tenant ID from the Azure portal
# tenant_id = 'common'
tenant_id = "ccccccc"
# Values from app registration
client_id = "aaaaaaaaaaaaaaaaaaaa"
client_secret = "bbbbbbbb"
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
scopes = ['User.Read']
# azure.identity
credential = DeviceCodeCredential(
tenant_id=tenant_id,
client_id=client_id)
graph_client = GraphServiceClient(credential, scopes)
request_body = Chat(
chat_type = ChatType.OneOnOne,
members = [
AadUserConversationMember(
odata_type = "#microsoft.graph.aadUserConversationMember",
roles = [
"owner",
],
additional_data = {
"user@odata_bind" : "https://graph.microsoft.com/v1.0/users('zzzzzzzz')",
}
),
AadUserConversationMember(
odata_type = "#microsoft.graph.aadUserConversationMember",
roles = [
"owner",
],
additional_data = {
"user@odata_bind" : "https://graph.microsoft.com/v1.0/users('zzzzzzzz')",
}
),
],
)
# result = await graph_client.chats.post(request_body)
# result = graph_client.chats.post(request_body)
loop = asyncio.get_event_loop()
result = loop.run_until_complete( graph_client.chats.post(request_body))
loop.close()
print (result)
