Twilio chat channel getMembers() method access forbitten

旧街凉风 提交于 2020-05-17 06:26:46

问题


After creating a channel in the Twilio Programmable Chat service, I am listening to the client events.

One of those events is the channelAdded event. In the hook, I have to retrieve the Members of the channel (in order to get the opposite members name in a binary room) like so

channel.getMembers()

When I do this, Twilio returns:

name: "SyncError"
message: "Access forbidden for identity (status: 403, code: 54007)"
status: 403
code: 54007

It would make sense if the user that is accessing that method wouldn't also be the author and a member of that channel.

Do I need to grant the author some special rights to access the channel?

Additional, secondary question

When I create a binary channel (2 members), I need to manually add the author as the member of the channel also like so:

        var channel = await this.client.createChannel({
            friendlyName: command.roomName,
            isPrivate: command.isPrivateRoom
        })
        var p1 = channel.add(command.currentUserId);
        var p2 = channel.add(command.oppositeUserId);
        await Promise.all([p1,p2])
        return command.roomName;

Is there a shortcut or a way to auto, add the Member on creation?


回答1:


Twilio developer evangelist here.

As per the documentation:

Once you've created a channel, a user must join it to begin receiving or sending messages on that channel.

Whether you create the channel in the client or server side, you need to specifically join the channel with your user before they have access to it. The only shortcut here is that you can call join() on the channel to join it with the authenticated user. For example:

await channel.join();
const members = await channel.getMembers();


来源:https://stackoverflow.com/questions/61728239/twilio-chat-channel-getmembers-method-access-forbitten

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!