简体   繁体   English

我想使用代理用户的密码和 email 地址从本地主机为 GraphApi 创建 Microsoft Teams 频道

[英]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.

相关问题 使用 nodejs 向微软团队频道发送消息 - Send message to microsoft teams channel using nodejs 我想从我的本地主机中删除以前的URL并将其替换为给定的自定义URL - I want to remove previous url from my local host and replace it with the custom url given 我想验证来自 javascript 个对象的 email 地址 - i want to validate email address from javascript objects 我希望我的不和谐机器人向用户提供的文本房间发送随机消息 [按频道 ID 或频道名称] - I want my discord bot to send a random message to a text room given by user [by channel id or channel name] 使用电子邮件和密码登录后,我需要将电子邮件传递到另一个页面,以便从 API 检索用户数据。 (反应) - After I login with email and password, I need to pass my email to the further page for retrieve the user data from the API. (React) 使用 firebase admin sdk 创建用户,可以使用 email 和密码登录 - Create user with firebase admin sdk that can signIn using email and password 如何允许我的用户使用 mobilen-number 或 email 地址在 Cognito 用户池上重置密码? - How to allow my users to use either mobilen-number or email address to reset their password on Cognito User Pools? 我可以使用 iframe 或其他技术将 Microsoft Teams 视频会议嵌入我的网站吗? - Can I embed a Microsoft Teams video meeting into my website using an iframe or other technology? 如何使用 javascript 从电子邮件地址中提取用户名? - How can I extract the user name from an email address using javascript? 从电子邮件地址查找用户 - Find user from email address
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM