Skip to content

Not able to access resource CreateChannel on ChannelType gaming for React SDK #1309

@kshitij3027

Description

@kshitij3027

Hi, i am experimenting with creating a chat based app with react using streamp api. I have been stuck on this place for some time now. I have essentially copied all the code provided in the documentation to create a channel and connect a user via the client.connectUser. I have correctly entered the api_key and user_token manually generated as in the documentation. Still the error message:

Error: StreamChat error code 17: GetOrCreateChannel failed with error: "User 'dave-matthews' with role channel_member is not allowed to access Resource CreateChannel on channel type gaming"

The code i am using in my App.js file goes something like this:

import React, { useEffect, useState } from 'react';
import { StreamChat } from 'stream-chat';
import {
Chat,
Channel,
ChannelHeader,
ChannelList,
MessageList,
MessageInput,
Thread,
Window,
} from 'stream-chat-react';
import '@stream-io/stream-chat-css/dist/css/index.css';

const filters = { type: 'messaging' };
const options = { state: true, presence: true, limit: 10 };
const sort = { last_message_at: -1 };

const client = StreamChat.getInstance('my-api-key');

const App = () => {

const [clientReady, setClientReady] = useState(false);
const [channel,setChannel] = useState(null)
useEffect(() => {
const setupClient = async () => {
try {
await client.connectUser(
{
id: 'dave-matthews',
name: 'Dave Matthews',
},
'my-userToken',
);
const channel = await client.channel('gaming', 'gaming-demo', {
name: 'My Gaming App',
members: ['dave-matthews', 'trey-anastasio'],
})
setChannel(channel);

    setClientReady(true);
  } catch (err) {
    console.log(err);
  }
};

setupClient();

}, []);

if (!clientReady) return null;

return (











);
};

export default App;

is persisting on my system.

error-screenshot

Can somebody please help me figure out what is the issue here? I have attached screenshot for reference

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions