Closed shrugs closed 6 years ago
The 401 here suggests that your instance locator or key are invalid / improperly formatted. Have you checked that you've copied them from the dashboard exactly as they appear?
The instance locator should be something like: v1:us1:abc-def-ghi-jkl
and the key should be something like: asjdkiubg91bg81n:jknav=10-2fn1uin1
Note the two :
s in the locator and single :
in the key
Yup! the same line, but with a string key chatkit.get_user_rooms({ id: '2640' })
works within the same rails console
instance
It feels like the backed is throwing on type conversion but somehow attributing the parsing incorrectly
Ah yep, okay I've spotted it. So the user ID you pass in via id
to the get_user_rooms
call was being used as the subject of the token without any stringifying going on, hence the token error (as we expect the subject to be a string).
I've fixed this as part of #16
Thanks!
const chatManager= new Chatkit.ChatManager({ instanceLocator:"v1:us1:xyz", userId:"HK", tokenProvider:new Chatkit.TokenProvider({ url:"http://localhost:8081/authenticate" }) }); chatManager.connect().then((currentUser)=>{ console.log("current User",currentUser)}) .catch((error)=>{ console.error(error)})
while running the above code from the client
to the node/express server:- app.post("/authenticate",(req,res)=>{ const {grant_type}=req.body; res.json(chatkit.authenticate({grant_type,userId:req.query.user_id})); });
throws an error:-
Logger.ERROR: error establishing presence subscription: Could not parse the token. More information can be found at https://docs.pusher.com/errors/authentication/jwt/invalid. Error object: {…} headers: Object { "Request-Method": "SUBSCRIBE" } info: {…} error: "authentication/jwt/invalid" error_description: "Could not parse the token" error_uri: "https://docs.pusher.com/errors/authentication/jwt/invalid" proto: Object { … } statusCode: 401 proto: Object { … }
Can someone help me out fixing the error. Note:- I provided the correct "instanceLocator" in my application (not the one mentioned above)
That looks like it's related to the https://github.com/pusher/chatkit-server-node repo. Please open a new issue there
Sure thanks, I raised the issue.
What?
Running:
gives you:
but since user ids are supposed to be strings, I'd expect an error closer to not being able to understand the query params.