How do I create a user on GetStream.io video chat?

124 Views Asked by At

I'm using the GetStream to create a video chat app. It's basically a one on one call that should last around 30 minutes.

I have tried various methods and functions, but I keep getting the error when starting a call that the user does not exist. I've tried anonymous, guest & other roles as well.

One thing I come back to is probably I'm not creating the user in the backend... however when I go to the documentation, I see no current way of doing that.

So, is it possible in it's current state to get this done?

How I start a call:

 guard let user = userController.user else { return }
        var members: [MemberRequest] = [.init(role: "guest", userId: user.id)]
        viewModel.startCall(
            callType: .development,
            callId: callId,
            members: members,
            ring: callFlow == .ringEvents
        )

How I generate a token:

app.post('/generateToken', async (req, res) => {


try {
    console.log(req.body)
    const { userId } = req.body;
if (!userId) {
  return res.status(400).json({ error: 'User ID is required' });
}

const token = serverClient.createToken(userId);

console.log(token);
res.status(200).json({ token });
  } catch (error) {
    console.error('Error generating token:', error);
    res.status(500).json({ error: 'Internal server error' });
  }
});

The token generates perfectly, and I use the same userId creating it as I do when entering a call.

Update:

I now have it so the user is fine as a guest... however a guest can't create a call. So I need to create a call as an admin, somehow. Which I've tried, but that's where the issue previously described lies.

0

There are 0 best solutions below