DEV Community

loading...

Discussion on: Python Chat Tutorial with Django and React

Collapse
danieltolczyk profile image
DanielTolczyk • Edited

I ran into this same issue. Couldn't figure out if it was because the chat app was named auth but not listed as an installed app, or if it was because the UnauthedRoute.js has the function name as the one in AuthedRoute.js. If it has something to do with the encoded user id in the generated token not matching the cool-sky-9 id user listed in the demo. Did everything I could to troubleshoot it and couldn't figure it out. I just know that no API call is being made. Honestly at a loss here on getting this to work.

Edit: I figure it out! The issue is that the key on the backend is being generated with obj.user.id in the serializer. This needs to be changed to obj.user.username if you want to match the username on the front end. In this particular demo cool-sky-9 or whatever have you. This will let you authenticate. The only issue you should run into after this is that you need your API keys from the CHAT part of the website. To have the chat functionality there is a free trial otherwise it's $499 a month from what I saw. So if you're looking at this for a personal project or something fun make sure you don't get charged!

Collapse
isaidspaghetti profile image
Taylor Graham

I had the same issue and this was the solution. The 'id' value from client.setUser must match the argument for client.createToken

const streamToken = client.createToken('exactNameHere');

await client.setUser(
{
id: 'exactNameHere'
},

Forem Open with the Forem app