laravel pusher service with passport authorization are failed

  laravel, laravel-echo, pusher, pusher-js

i’m trying to subscribe to a private channel using pusher service ,but i got returned to log in route

here is the echo initialization

window.Echo = new Echo({
broadcaster: 'pusher',
key: '4e93bd9bf6826a5564d2' /*process.env.MIX_PUSHER_APP_KEY*/,
cluster: 'ap2' /* process.env.MIX_PUSHER_APP_CLUSTER */,
forceTLS: true,
auth: {
    headers: {
        Authorization: `Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI0IiwianRpIjoiYmVjNTBhNzcwZjBiOWZhMzU1NDNhZWMyYWE4NzhkZWQ1YzVhNzJlZTYzNjE3Y2U5OWUxYzcwM2ZhNDcwMTUzZGY0NDZjOGU5OGUzMWNjNWYiLCJpYXQiOiIxNjE3ODY3MDIxLjkwNDAyMSIsIm5iZiI6IjE2MTc4NjcwMjEuOTA0MDI5IiwiZXhwIjoiMTYyMDQ1OTAyMS40NjE2MDUiLCJzdWIiOiIxNyIsInNjb3BlcyI6WyJhZG1pbiJdfQ.KRcrnK65BSavt41BQudlak-IcsUjvgzu37X2SYKTsdXWXzfWe4HiBpJUH-MOIaPuhVzGK7ufACYLuYVb5eBO5lShUL35ScnvgIQ73x2e5nqHpf28NzK8QWR1u-f-g3kPXV2pHrIZYrpfS6EYJuGRRInj8sqxnvn1Kp3_ea9a4hfCHWmq2GQ2rYTQ49nt3CWYf-OXoHHF7NmRocCyYsmItIPEPekCS5q4swQ7rVt0HmL5T3j51eds7UeWcpi0FPjU_Krq4umYqlkOAFcEo46NPCXqSUsuhKI7D1wwJOl5A594wfG7MOYF7weiXCrpdzvWoTiRZMjPRBleuFpGIRWIJIzo9hLIIODFJIMESI65NS94bsCqB6X81fas496lWsG_xBgKo8WG58atu7WToveE99DmjgNywpr_Z6xqwKRrVrOzxHoAwTyI0_atJQuC0NFXjLOD2qyCdLBiGoGpzYuGDE-ZAXtYQGg2wEKRR1rDBjAwv3Q7x33SmAgxqs4Ehp7IAu8-673q04S7kFlbru8LaVqhizf8UAitb2xBc6NOVd1CfMdb4XlVx_gZNc_jiPYFxdePxBssb7LjwkfspEr7g-lagqlrzLiWfkeeyS08wnd-jk4jS4hXpj-KHtw_KSyH9ijeAOdJNJ7Z07nojYV7yl8dKwTqh3C9-GCt3MB5rX4`
    },
} });

and here i’ve added the same auth token to the pusher object

window.Echo.connector.pusher.config.auth.headers['Authorization'] = 'Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiI0IiwianRpIjoiYmVjNTBhNzcwZjBiOWZhMzU1NDNhZWMyYWE4NzhkZWQ1YzVhNzJlZTYzNjE3Y2U5OWUxYzcwM2ZhNDcwMTUzZGY0NDZjOGU5OGUzMWNjNWYiLCJpYXQiOiIxNjE3ODY3MDIxLjkwNDAyMSIsIm5iZiI6IjE2MTc4NjcwMjEuOTA0MDI5IiwiZXhwIjoiMTYyMDQ1OTAyMS40NjE2MDUiLCJzdWIiOiIxNyIsInNjb3BlcyI6WyJhZG1pbiJdfQ.KRcrnK65BSavt41BQudlak-IcsUjvgzu37X2SYKTsdXWXzfWe4HiBpJUH-MOIaPuhVzGK7ufACYLuYVb5eBO5lShUL35ScnvgIQ73x2e5nqHpf28NzK8QWR1u-f-g3kPXV2pHrIZYrpfS6EYJuGRRInj8sqxnvn1Kp3_ea9a4hfCHWmq2GQ2rYTQ49nt3CWYf-OXoHHF7NmRocCyYsmItIPEPekCS5q4swQ7rVt0HmL5T3j51eds7UeWcpi0FPjU_Krq4umYqlkOAFcEo46NPCXqSUsuhKI7D1wwJOl5A594wfG7MOYF7weiXCrpdzvWoTiRZMjPRBleuFpGIRWIJIzo9hLIIODFJIMESI65NS94bsCqB6X81fas496lWsG_xBgKo8WG58atu7WToveE99DmjgNywpr_Z6xqwKRrVrOzxHoAwTyI0_atJQuC0NFXjLOD2qyCdLBiGoGpzYuGDE-ZAXtYQGg2wEKRR1rDBjAwv3Q7x33SmAgxqs4Ehp7IAu8-673q04S7kFlbru8LaVqhizf8UAitb2xBc6NOVd1CfMdb4XlVx_gZNc_jiPYFxdePxBssb7LjwkfspEr7g-lagqlrzLiWfkeeyS08wnd-jk4jS4hXpj-KHtw_KSyH9ijeAOdJNJ7Z07nojYV7yl8dKwTqh3C9-GCt3MB5rX4';

when i try to subscribe to a private channel as here

let chatting_channel = window.Echo.private('private_chat.17');

that is what i got

XHRPOST http://127.0.0.1:8000/broadcasting/auth  [HTTP/1.1 302 Found 1175ms]
XHRGET http://127.0.0.1:8000/general/login   [HTTP/1.1 200 OK 1550ms]

at channels file

    Broadcast::channel('private_chat.{user_id}', function ($user) {
          return true;
    });

and at BroadcastServiceProvider

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

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

any help please.. ??

Source: Laravel

Leave a Reply