im trying to publish a message using the code in the documentation but i get the error that the user does not have permission.
im log in the user using REST and i have the user token. how can i set it for my js functions?
Hey
but how to send the logged in user token? i tried ‘user-token’ in the headers and that didn’t work. should i use codeless to send messages since im logged in using codeless. and keep using the js SDK to subscribe to channels
var channel = “TestChannel”,
message = “Hello, world!”,
pubOps = new Backendless.PublishOptions({
headers: {
city: “Tokyo”,
‘user-token’: “value”
}
});Backendless.Messaging.publish( channel, message, pubOps )
.then( function( response ) {
})
.catch( function( error ) {
});
-
if you use REST you have to add “user-token” as HTTP Header
-
adding the header into Backendless.PublishOptions is a wrong way
-
if you send messages from Codeless or any other Business Logic lang, ServerCodeUser role will be used
-
Codedless you can logging user using corresponding block, or if you call your ApiService as logged in user from the client the user will assigned inside BusinessLogic automatically
-
if you use JS-SDK after calling login api all the requests will be as from logged in user
Regards, Vlad
i will use codeless then.
Thanks!