douyoufan7881 2017-10-05 14:06
浏览 83

Pusher:无法检索身份验证信息

Using Laravel echo, pusher and vuejs.

Whenever I try to join a private channel(the channel of the own user) y get this error

"Pusher : Couldn't retrieve authentication info. 419Clients must be authenticated to join private or presence channels. See: https://pusher.com/docs/authenticating_users"

Here is the moment I join a the channel:

Echo.private('App.User.' + response.data.currentUser)
.listen('Event',(e)=>{});

response.data.currentUser does contain correctly the id of the user.

Here is the channel.php

Broadcast::channel('App.User.{id}', function ($user, $id) {
    if (Auth::user()->id == (int) $id) {
        return ['STATUS' => 'OK'];
    } else {
        return false;
    }
});

How can I solve this

  • 写回答

2条回答 默认 最新

  • douyiavxxh02727 2017-10-06 14:50
    关注

    I solved the issue by adding this

    import Echo from 'laravel-echo'
    
    window.Pusher = require('pusher-js');
    
    window.Echo = new Echo({
    
        "authEndpoint": "/your-project-name/broadcasting/auth",
        broadcaster: 'pusher',
       key: '####################',
       cluster : "mt1",
       encrypted: true
    
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退