Getting 401 Unauthorized on broadcasting/auth for presence channel
Note: Same middleware I'm using on other end-point with same token and giving me response
here is channel.php code
Broadcast::channel('broadcast-restaurant-message.{id}', function ($restaurant, $id) {
if( (int) $restaurant->id === (int) $id) {
return [ 'id' => $restaurant->id, 'name' => $restaurant->name, 'image' => $restaurant->image ]; } });
BroadcastServiceProvider.php code
Broadcast::routes(["prefix" => "api", "middleware" => ['auth:restaurant', 'scopes:restaurant']]);
auth.php
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'admin' => [
'driver' => 'session',
'provider' => 'admins',
],
'restaurant' => [
'driver' => 'passport',
'provider' => 'restaurants',
'hash' => false,
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
'hash' => false,
],
],
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\Models\User::class,
],
'admins' => [
'driver' => 'eloquent',
'model' => App\Models\Admin::class,
],
'restaurants' => [
'driver' => 'eloquent',
'model' => App\Models\Restaurant::class,
],
]
I pass additional attributes in
Broadcast::routes(["prefix" => "api", "middleware" => ['auth:restaurant', 'scopes:restaurant']]);