Token Authentication
How to setup Sanctum Bearer token-based authentication for Laravel Echo.
Last updated
How to setup Sanctum Bearer token-based authentication for Laravel Echo.
Last updated
Token-based authentication is not recommended for SPA applications. Still, it might be useful when you cannot host it on the same TLD or have a mobile or desktop application built with Nuxt (e.g. based on Capacitor).
To explicitly set this authentication mode, update echo.authentication.mode
configuration property to token
.
You can check the official Laravel documentation here - .
You should already have an authenticated user by submitting credentials to your login endpoint, for instance, using the module.
Default token storage uses cookies to keep the Authentication token and automatically load it for Echo channel authorization requests. However, you are free to define custom storage in your app.config.ts
by implementing an interface (especially, when cookies are not supported, for example - Capacitor, Ionic, LocalStorage, etc).
Check this section for more details - .