颤音异常错误创建streamchat频道

发布于 2025-01-26 21:40:33 字数 695 浏览 4 评论 0 原文

您好,我正在尝试使用streamchat.io api来构建聊天应用程序,但是当我尝试创建一个频道时,我会得到此错误 streamChatnetworkerror(streamchatnetworkerror(代码:1000,消息:未经授权,未定义的标记)))

这是我设置的代码加入频道

Future<void> createChannel(BuildContext context) async {
try {
  final currentUser = FirebaseAuth.instance.currentUser;
  final userID = currentUser!.uid;
  final client = StreamChatCore.of(context).client;
  final channel = client.channel("messaging", id: userID, extraData: {
    "name": _name.text.trim(),
  });
  AccountUpdate.storeChannel(channel);
  await channel.watch();
  print("this is the channel output $channel");
} catch (e) {
  print(e);
}

} 我已经禁用了验证检查,因此无需秘密

Hello I'm trying to use StreamChat.io API to build a chat app but when I try to create a channel I get this error StreamChatNetworkError (StreamChatNetworkError(code: 1000, message: Unauthorised, token not defined))

Here is the code I set to join a channel

Future<void> createChannel(BuildContext context) async {
try {
  final currentUser = FirebaseAuth.instance.currentUser;
  final userID = currentUser!.uid;
  final client = StreamChatCore.of(context).client;
  final channel = client.channel("messaging", id: userID, extraData: {
    "name": _name.text.trim(),
  });
  AccountUpdate.storeChannel(channel);
  await channel.watch();
  print("this is the channel output $channel");
} catch (e) {
  print(e);
}

}
And I have disabled Auth checks so there is no need for a secret

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

撩心不撩汉 2025-02-02 21:40:33

在流团队的帮助下,我发现您需要首先建立一个连接的用户才能观看频道

await client.connectUser(
    User(id: "john"),
    client.devToken('john').rawValue,
  );

编辑:上述开发人员令牌(需要禁用身份验证)。在生产环境中,您需要使用流的后端客户端 。或出于开发目的,您可以使用在线代币发电机有关

连接和身份验证的更多信息: https://getStream.io/chat/chat/chat/docs/flutter-dart/tokens_and_authentication/?language= darg=

dart https://getStream.io/chat/flutter/tutorial/“ rel =“ nofollow noreferrer”>入门教程寻求更多帮助。

With help from the Stream team, I figured out that you need to establish a connected user first in order to watch a channel

await client.connectUser(
    User(id: "john"),
    client.devToken('john').rawValue,
  );

EDIT: The above makes use of developer tokens (which requires authentication to be disabled). In a production environment you will need to generate frontend tokens using one of Stream's backend clients. Or for development purposes you can use the online token generator https://getstream.io/chat/docs/flutter-dart/token_generator/?language=dart

More info on connections and authentication: https://getstream.io/chat/docs/flutter-dart/tokens_and_authentication/?language=dart

See the Stream Chat Flutter getting started tutorial for more help.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文