When using RTSession.newRequest() to make a request, such as a LogEvent, under what credentials is the request made?
The background of the question is that I want to have certain events that can only be called from real time cloud code, which is an authoritative server in my case. E.g. the "updatePlayerRank" event should only be possible to be called from RT cloud code.
Currently, all I'm getting is an "authentication": "NOTAUTHORIZED" error on the requests, no matter how I set the permissions.
Best Answer
T
Tech Support
said
about 6 years ago
Hi Christian
RealTime requests are sent with a system credential. So they are able to make any call.
I suspect you are not setting the playerId of the request before you are sending it. Leading to the NOTAUTHORIZED error.
RTSession.onPacket(123, function(packet){
var currentPlayerId = packet.getSender().getPlayerId();
RealTime requests are sent with a system credential. So they are able to make any call.
I suspect you are not setting the playerId of the request before you are sending it. Leading to the NOTAUTHORIZED error.
RTSession.onPacket(123, function(packet){
var currentPlayerId = packet.getSender().getPlayerId();
RTSession.newRequest()
.createLogEventRequest()
.setEventKey("KEY")
.setPlayerId(currentPlayerId)
.send(function(response){
//Process response
})
})
Hope that helps.
C
Cristian Bontas
said
about 6 years ago
Thanks for the prompt reply.
I see.
Indeed, I wasn't setting any player ID, precisely because I wanted the call to be made with system credentials instead of the player's.
BTW, the RTRequestBuilder is not documented at all, the only mention being "signature newRequest()
returns RTRequestBuilder
A builder object for creating and sending requests to the GameSparks platform".
Customer Support
said
about 6 years ago
Hi Cristan,
We've added a section to the Client API for the RT Scripts to help with this. You can find that page and the examples here. If you have any further questions just let us know.
Regards,
Liam
C
Cristian Bontas
said
about 6 years ago
Hello
Does it matter which player ID I set for the request? For example, could I create a dummy player that will never actually play, but only use its ID for such calls?
C
Cristian Bontas
said
about 6 years ago
Ran a test, seems to be working with a dummy player ID. Simply insert a record from the NoSQL page into the players collection (I've only defined the username), copy the generated ID and it seems to work just fine.
Cristian Bontas
Hello
When using RTSession.newRequest() to make a request, such as a LogEvent, under what credentials is the request made?
The background of the question is that I want to have certain events that can only be called from real time cloud code, which is an authoritative server in my case. E.g. the "updatePlayerRank" event should only be possible to be called from RT cloud code.
Currently, all I'm getting is an "authentication": "NOTAUTHORIZED" error on the requests, no matter how I set the permissions.
Hi Christian
RealTime requests are sent with a system credential. So they are able to make any call.
I suspect you are not setting the playerId of the request before you are sending it. Leading to the NOTAUTHORIZED error.
RTSession.onPacket(123, function(packet){
var currentPlayerId = packet.getSender().getPlayerId();
RTSession.newRequest()
.createLogEventRequest()
.setEventKey("KEY")
.setPlayerId(currentPlayerId)
.send(function(response){
//Process response
})
})
Hope that helps.
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstTech Support
Hi Christian
RealTime requests are sent with a system credential. So they are able to make any call.
I suspect you are not setting the playerId of the request before you are sending it. Leading to the NOTAUTHORIZED error.
RTSession.onPacket(123, function(packet){
var currentPlayerId = packet.getSender().getPlayerId();
RTSession.newRequest()
.createLogEventRequest()
.setEventKey("KEY")
.setPlayerId(currentPlayerId)
.send(function(response){
//Process response
})
})
Hope that helps.
Cristian Bontas
Thanks for the prompt reply.
I see.
Indeed, I wasn't setting any player ID, precisely because I wanted the call to be made with system credentials instead of the player's.
BTW, the RTRequestBuilder is not documented at all, the only mention being "signature newRequest() returns RTRequestBuilder A builder object for creating and sending requests to the GameSparks platform".
Customer Support
Hi Cristan,
We've added a section to the Client API for the RT Scripts to help with this. You can find that page and the examples here. If you have any further questions just let us know.
Regards,
Liam
Cristian Bontas
Hello
Does it matter which player ID I set for the request? For example, could I create a dummy player that will never actually play, but only use its ID for such calls?
Cristian Bontas
Ran a test, seems to be working with a dummy player ID. Simply insert a record from the NoSQL page into the players collection (I've only defined the username), copy the generated ID and it seems to work just fine.
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics