NullVoxPopuli
NullVoxPopuli

Reputation: 65173

Pusher: "Uncaught TypeError: Cannot call method 'scopedTo' of undefined" when authing

I have my app_key, key, and secret in my ApplicationController

my PusherController:

  def auth
    if current_user
      auth = Pusher[params[:channel_name]].authenticate(params[:socket_id],
        :user_id => current_user.id, # => required
        :user_info => { # => optional
          :name => current_user.name,
          :email => current_user.email
        }
      )
      render :json => auth
    else
      render :text => "Not authorized", :status => '403'
    end
  end

My js

var pusher = new Pusher("key");
Pusher.channel_auth_endpoint = "/pusher/auth";
Pusher.channel_auth_transport = 'json';

channel = pusher.subscribe("presence-content_editing");

I'm pretty sure I followed the inscrutions http://pusher.com/docs/presence-1.6

Nwo I"m just confused as to why I get this error

this is the error :
Uncaught TypeError: Cannot call method 'scopedTo' of undefined
Pusher.Channel.PrivateChannel.authorizepusher.min.js:38
Pusher.subscribepusher.min.js:13
Pusher.subscribeAllpusher.min.js:12
connection.bind.bind.cpusher.min.js:10
a.emitpusher.min.js:17
jpusher.min.js:25
_machine.b.Machine.connectedPostpusher.min.js:29
apusher.min.js:19
c.transitionpusher.min.js:20
w

Upvotes: 0

Views: 1566

Answers (2)

NullVoxPopuli
NullVoxPopuli

Reputation: 65173

Remove these two lines:

Pusher.channel_auth_endpoint = "/pusher/auth";
Pusher.channel_auth_transport = 'json';

Upvotes: 1

leggetter
leggetter

Reputation: 15467

This Presence resource looks out of date - we'll need to remove it.

You should be using the latest version of the Pusher JavaScript library which you can find here:

http://js.pusher.com/1.11/pusher.min.js

And following authentication as outlined in the authenticating users docs. The server code you have looks fine. The error is on your client and I'm hopeful that updating the JavaScript library will resolve it - we've not had any support requests about this issue.

Upvotes: 0

Related Questions