How to use Laravel Echo and Pusher in laravel 5.8 with API authentication

Posted 2 months ago by spacedog4

I'm trying to build a real-time chat app, but I'm having problem with laravel echo in vue js

This chat needs an api authentication, so in my broadcast it need to

this next code is in my main app.js file

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: process.env.MIX_PUSHER_APP_KEY,
    cluster: process.env.MIX_PUSHER_APP_CLUSTER,
    logToConsole: true,
    encrypted: true,
    auth: {
        headers: {
            Authorization: `Bearer TOKEN`
        },
    },
    authEndpoint: "/api/broadcasting/auth",
})

How can I get this Beare Token (that I pass on the URL) and use it in my app.js file, dinamyc since It could be any user

Please sign in or create an account to participate in this conversation.