0
votes

I'm using Laravel to build a messaging system, so that's why i'm using events broadcasting, also i'm using passport for authentication.

I changed the BroadcastServiceProvider boot() method by setting the middleware auth:api Also i'm adding Authorization : Bearer mytoken in my postman post request.

public function boot()
{
    Broadcast::routes(['middleware' => ['auth:api']]);
    require base_path('routes/channels.php');
} 

My problem is when i want to try to authenticate on myhost//broadcasting/auth I get this response:

403 forbidden

1
Hello, edit your question to include details about how are you broadcasting the events, how are you listening to this events and finally, how are you making the request. Also, explain your use case, maybe there's a better way to handle it. To more guidance, check this article: How to AskKenny Horna
Hello, actually i'm just using postman to authenticate on /broadcasting/authAyèch Hamza
I know. You said that, but without code I can't tell where the problem is.Kenny Horna

1 Answers

0
votes

Not really an answer other than it doesn't seem to work in Postman. No mater how I configure the request it still returns a 403. However using Laravels bootstrap JS or even an external file with Echo or Pusher-js, it works.

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    encrypted: true,
    auth: {
        headers: {
            'Authorization': 'Bearer ' + jwt
        },
    },
});