javascript - PubNub Presence Repeating 403 Forbidden Error -
i'm trying use pubnub presence in app , i'm getting repeating forbidden error. have permissions enabled in pubnub admin portal.
here subscription code:
var initsettings: pubnub.iinitsettings = { publish_key: "mypubkey", subscribe_key: "mysubkey", uuid: "myuuid", auth_key: "myauthkey" }; this.pubnub = pubnub(initsettings); console.log(this.pubnub); var subscribesettings: pubnub.isubscribesettings = { channel: "chat", presence: this.userconnected, message: this.processmessage }; this.pubnub.subscribe(subscribesettings);
this userconnected
callback:
userconnected = (m: any) => { var herenowsettings: pubnub.iherenowsettings = { channel: this.channelstring, callback: (message: any) => { this.channelcount++; } }; this.pubnub.here_now(herenowsettings); };
i repeating error says
pubnub-3.7.14.js:2644 http://ps17.pubnub.com/subscribe/mysubkey/chat%2cchat-pnpres/0/0?uuid=myuuid&pnsdk=pubnub-js-web%2f3.7.14 403 (forbidden)
i don't understand why i'm getting error. can explain this?
update:
i added secret key , grant pubnub config:
createpubnubconnections() { let initsettings: pubnub.iinitsettings = { publish_key: publishkey, subscribe_key: subscribekey, uuid: uuid, auth_key: authkey, secret_key: secretkey }; this.pubnub = pubnub(initsettings); console.log(this.pubnub); let subscribesettings: pubnub.isubscribesettings = { channel: "chat", presence: this.userconnected, message: this.processmessage }; this.pubnub.subscribe(subscribesettings); let grantsettings: pubnub.igrantsettings = { read: true, callback: (message: any) => { console.log(message); } }; this.pubnub.grant(grantsettings); }
however, i'm getting error says
missing secret key
pubnub access manager & granting permissions
if have access manager enabled server must grant permission read
on channel , presence channel if going subscribe (with presence) on channel.
you said:
permissions enabled in pubnub admin portal
... not enable (grant) permissions in admin portal, grant permission in code using secret key.
see following links how use access manager grant permissions:
Comments
Post a Comment