Closed Gabriel416 closed 6 years ago
Looks like the user was created in the pusher dashboard. But I can't seem to connect. Please let me know if I'm missing anything silly, or if more info is needed. Thanks.
Hi Gabriel416,
For the second last image, where you can see the Ajax response which has the status, body, and header. So, instead of sending those entire details, return the body only and set the status code as whatever you get.
So, the JSON returned will look like this:
{ "access_token":"receivedToken", "token_type":"bearer", "expires_in":86400 }
Also, hope that the rootState.authentication.token
, generates the correct JWT.
Hello @kkcodes ! server side I'm sending the body now and I'm running into this
This is what I'm getting back from my server
rootState.authentication.token
is an api token needed to make requests to my server and I have verified it is correct.
Hi @Gabriel416,
The error is complaining that there is no user ID in your token, which the connection request needs to identify who the user is. Can I see the code you're using to generate the token?
The register method is where I'm creating the chatkit user.
this method is the one that gets hit for the tokenProvider
this is what my ChatkitService looks like
What version of the node SDK are you using? In the latest version at least, authenciate
takes a single object with a userId
. e.g.
app.post('/auth', (req, res) => {
const authData = chatkit.authenticate({
userId: req.query.user_id
});
res.status(authData.status)
.send(authData.body);
})
@callum-oakley thank you works like a charm now! I'm using "@pusher/chatkit-server": "^0.12.2"
. I was loosely following https://pusher.com/tutorials/chat-adonisjs#get-user-details and it seems like there is some outdated stuff. Thanks again cheers.
Great to hear! Thanks for letting us know :)
I'm trying to set up chatkit for my app and everything seems to work until I try to connect and get the currentUser. Looks like one request from the server results in a 204 and the other request seems fine. The function below is fired once on mount of a component.