instedd / aida-ui

1 stars 2 forks source link

What is the correct authorization to join a channel/bot via JS client? #239

Closed zontarian closed 6 years ago

zontarian commented 6 years ago

Hi, I'm trying to connect to a Bot I've created, using a JS client (so, websockets). This is my first go at it. I'm using as a starting point https://hexdocs.pm/phoenix/js/#phoenix https://github.com/instedd/aida-ui/blob/master/app/javascript/components/ChatClient.jsx

So far I've managed to open the Phoenix socket and connect to it, but when I try to join the channel Iike this

let socket = new Socket('wss://aida.xxxxxx.org/socket');
socket.connect();
let channel = socket.channel('bot:'+botId, {'access_token': accessToken}); //<-- error here

I get

{reason: "unauthorized"}

botId is a number, the one I see in this URL https://aida.xxxxxxxxx.org/b/10/channel (10). While accessToken is the token I've written in the Channel tab of my Bot configuration, under the heading screen shot 2018-09-19 at 15 46 29

So, what is the correct authorization? Thanks Walter

zontarian commented 6 years ago

Well..it seems my parameters were wrong. By debugging the chat in the "Behaviour" tab, I discovered

With these two parameter my sample connection worked and I was able to join the channel.

Now the question is, how to infer these values from the info on the web site? :) Maybe there is a service to call beforehand..

macoca commented 6 years ago

Closed in favor of https://github.com/instedd/aida/issues/276