mardi 13 février 2018

Passport Auth error 500 with Laravel-echo-server

my current condition:

  1. Have installed laravel-echo-server ( https://github.com/tlaverdure/laravel-echo-server )
  2. Using passport for authentication
  3. trying to connect to the private channel with a bit configuration in bootstrap.js

this is my laravel-echo-server configuration:

{
"authHost": "localhost:8002",
"authEndpoint": "/broadcasting/auth",
"clients": [
    {
        "appId": "53d5246b1d87eddb7easdfads",
        "key": "fb3d04b4d65e04d0de4d0f154sdfa0303f23"
    }
],
"database": "redis",
"databaseConfig": {
    "redis": {},
    "sqlite": {
        "databasePath": "/database/laravel-echo-server.sqlite"
    }
},
"devMode": true,
"host": null,
"port": "6001",
"protocol": "http",
"socketio": {},
"sslCertPath": "",
"sslKeyPath": "",
"sslCertChainPath": "",
"sslPassphrase": "",
"apiOriginAllow": {
    "allowCors": true,
    "allowOrigin": "localhost:8002",
    "allowMethods": "GET, POST",
    "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
}}

my BroadcastServiceProvider.php:

public function boot()
{
    Broadcast::routes(['middleware' => 'auth:api']);

    require base_path('routes/channels.php');
}

my bootstrap.js configuration:

window.Echo = new Echo({
broadcaster: 'socket.io',
host: window.location.hostname + ':6001',
auth:
{
    headers:
    {
        'Accept': 'application/json',
        Authorization: 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImYyNjgzZmZiMzVlZjQ3ODQxYTY0...'
    }
},
csrfToken: token.content});
window.Echo.private('booking-list-channel.1')
.listen('.booking-list-event', (e) => {
    console.log(e.booking);
});

when I try to access localhost:8002, I got this:

[15:39:56] - IjxD9cqfxppeC2xZAAAA could not be authenticated to private-booking-list-channel.1
{"status_code":500,"error":"Unauthenticated."} Client can not be authenticated, got HTTP status 500

let me know if you need more information about my existing codebase.

Thank you.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire