deepbrook/Pysher

Getting initial socket_id for auth endpoint - Docs request

Closed this issue · 5 comments

Similar to #22

Server:
const auth = pusher.authenticate(socket_id, channel_name);
socket_id and channel_name are required for the auth payload to the endpoint.

Client:
How does one get the initial socket_id to post to an auth endpoint to get the auth string during the initialization of the client?

Currently the private channel example has the secret passed in via an command line argument.
https://github.com/nlsdfnbch/Pysher/blob/master/examples/private.py

Perhaps an example of subscribing to a private channel with an auth endpoint could be added to the docs.

up

Someone know how to set the channel authorization endpoint? :(

You get the socket_id on the json string parameter passed to the function bound to the pusher:connection_established event

@eliasjtg you need to manually send the http request to the auth endpoint

Can you please share an example code snippet to get socket_id which needs to be send to get auth

import json
import pysher

pusher = pysher.Pusher('pusher_app_key')
pusher.connection.bind('pusher:connection_established', connect_handler)
pusher.connect()

def connect_handler(data):
    data = json.loads(data)
    print(data.get('socket_id'))