Closed acrolink closed 6 years ago
The arguments to verify are key_source, token, max_age, opts
, so in your example, you would write Phauxth.Token.verify(socket, token, 86400)
(the opts are optional).
@riverrun I have tried that, but I am getting this error:
Request: GET /socket/websocket?token=SFMyNTY.eyJzaWduZWQiOjE1MjUzNzk5MjUsImRhdGEiOjF9.JyIVTHaEozGkclPEh1QpiuTHjOCrXJV1feeZUvOZSE8&vsn=2.0.0
** (exit) an exception was raised:
** (ArithmeticError) bad argument in arithmetic expression
(phauxth) lib/phauxth/token.ex:126: Phauxth.Token.handle_verify/2
(onlist) lib/onlist_web/channels/user_socket.ex:24: OnlistWeb.UserSocket.connect/2
(phoenix) lib/phoenix/socket/transport.ex:191: Phoenix.Socket.Transport.do_connect/7
(phoenix) lib/phoenix/transports/websocket.ex:89: Phoenix.Transports.WebSocket.init/2
(phoenix) lib/phoenix/endpoint/cowboy_websocket.ex:12: Phoenix.Endpoint.CowboyWebSocket.init/3
(cowboy) /srv/phx/onlist/deps/cowboy/src/cowboy_handler.erl:64: :cowboy_handler.handler_init/4
(cowboy) /srv/phx/onlist/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
Works as designed, I was passing the max_age
wrongly to the function.
I am trying to verify the token inside:
But getting errors. How to use
Phauxth.Token.verify
instead ofPhoenix.Token.verify
to verify thePhauxth
token in this context (channels and sockets)?