[英]I want to create a Microsoft Teams channel for GraphApi from my local host using the password and email address of the surrogate user
I want to create a Microsoft Teams channel for GraphApi from my local host using the password and email address of the surrogate user.我想使用代理用户的密码和 email 地址从本地主机为 GraphApi 创建 Microsoft Teams 频道。
I would like to create a channel from GraphApi using Microsoft email and password credentials from an unauthenticated localhost server.我想使用 Microsoft email 和来自未经身份验证的本地主机服务器的密码凭据从 GraphApi 创建一个通道。
[Development environment] ・local host ・ Nodejs ・ Lib (@azure / ms-rest-nodeauth) 【开发环境】·本地主机·Nodejs·Lib(@azure/ms-rest-nodeauth)
[code] [代码]
const userName = process.env["SYSTEM_USERNAME"];
const passWord = process.env["SYSTEM_PASSWORD"];
const applicationTokenCredentials = await loginWithUsernamePasswordWithAuthResponse(
userName,
passWord,
{tokenAudience: 'https://graph.microsoft.com'}
);
const accessToken = (await applicationTokenCredentials.credentials.getToken()).accessToken;
//addChannelsMember
const teams_id = "xxxxxxxxxxxxxxxxxxxxxx";
const channel_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const user_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const res = await fetch(
`https://graph.microsoft.com/v1.0/teams/${teams_id}/channels/${channel_id}/members`,
{
headers: {'Authorization': `Bearer ${accessToken}`, 'Content-Type': "application/json"},
method: "POST",
body: JSON.stringify({
"@odata.type": "#microsoft.graph.aadUserConversationMember",
"roles": ["owner"],
"user@odata.bind": `https://graph.microsoft.com/v1.0/users('${user_id}')`
})
}
);
[error] [错误]
{
error: {
'Unauthorized',
message: 'Caller does not have the required permissions for accessing this API. AllowedPermissions:'ChannelMember.ReadWrite.All'',
innerError: {
date: '2021-02-12T09:06:37',
'request-id': 'f6bee689-6800-4ee8-xxxxxxxxxxxxxx',
'client-request-id': 'f6bee689-6800-xxxxxxxxxxxxxxxxxxxxx'
}
}
}
please help me!请帮我!
I think your error message has clearly indicated the cause of your error, you lack the ChannelMember.ReadWrite.All permission.我认为您的错误消息已经清楚地表明了您的错误原因,您缺少ChannelMember.ReadWrite.All权限。
Go to Azure portal > Azure AD > App registrations > your app > API permissions . Go 到Azure 门户> Azure AD >应用注册>您的应用> ZDB974238714CA8ACE1634 权限。 Then add the ChannelMember.ReadWrite.All permission, and grant admin consent for this permission.然后添加 ChannelMember.ReadWrite.All 权限,并为此权限授予管理员同意。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.