Actually, for external app, an auth route should be setup and return a token from pusher library.
Documentation below
https://pusher.com/docs/authenticating_users#implementing_private_endpoints
I want to setup a private channel with pusher for broadcasting events between my laravel app and my react native app.
I'm using laravel passport for the oauth server.
And here is what I have implemented:
react native pusher channel subscription:
let token = 'oauthUserToken';
var pusher = new Pusher('pusher_key', {
authEndpoint: 'http://url.com/broadcasting/auth',
auth: {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer ' + token
}
},
cluster: 'ap1',
encrypted: true
});
var channel = pusher.subscribe('private-hello');
Event class:
class HelloPusher implements ShouldBroadcast
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $message;
public function __construct($message)
{
$this->message = $message;
}
public function broadcastOn()
{
return new PrivateChannel('hello');
}
}
routes/channels.php:
Broadcast::channel('hello', function () {
return true;
});
BroadcastingServiceProvider is commented out in the config/app.php.
And I keep having Pusher : Couldn't get auth info from your webapp : 500.
When I use laravel Echo and Vue on the webapp, private channel subscription is working properly.
I believe it is related to the fact the Broadcast event can't find any user logged in. Any way to use the oauth authorization from laravel passport instead?
Thank you
Actually, for external app, an auth route should be setup and return a token from pusher library.
Documentation below
https://pusher.com/docs/authenticating_users#implementing_private_endpoints
Please or to participate in this conversation.