Edit : the bug was on my side Nothing happened here …
Hi !
I’m trying to update a Lobby custom data with a Service Account, but I get an error stating that only the host of the Lobby can do that.
The Lobby is created from a connected player, and on my game server I need to update custom data from that Lobby. On my server, I use a Service Account for API call, but when trying to update Lobby custom data it doesn’t work …
The Service Account has the right role to call this API (Unity Services Web API docs).
Hi there @BSimonSweet , I noticed this has been marked resolved. Mind sharing what the implementation mistake was?
For future forum browsers also be aware that there are some features of authentication available to you to accomplish various architectures.
Firstly, there is a Bulk Update api that can be used as the heavy hammer for a Service Account to update the Lobby: Unity Services Web API docs
Also, you can impersonate a user if needed with the impersonated-user-id
header on the api endpoint you are trying to call. Though you probably should only do that for actions you’d normally expect a user to be taking.
Finally, if you are using the Unity dedicated game servers (Multiplay) there is a token available to you within that server context which might be useful- Call from Unity game server (Multiplay)
// You can retrieve a Game Server Hosting (Multiplay) token by running the following request on the game server:
curl -X GET http://localhost:8086/v4/token
//The request would return a response in the format below:
{"token":"<BEARER_TOKEN>", "error":""}
Hi ! The mistake was on the method I implemented to perform a Lobby Data Update request, nothing related to the API or the SDK itself. I have a condition before performing the request that was checking the local player ID to the lobby host ID, and was failing the call if not the same. But I also store the Service Account ID in the same field as the local player ID (on my server build), so the condition was not true …
And I totally overlooked the API to get a token on a Multiplay instance ! Right now, I pass the service account credential from the Configuration Variables, in the Build Configuration. The token has all the authorization to call any API ?
Ah, gotcha. Glad you figured it out!
Unfortunately, no the token doesn’t work on every single endpoint. I’ll look to have this officially documented at some point, but for now below is a list of services that should work. If you have other ones that you were thinking of I can feed that back to the relevant folks. Good luck!
-
Cloud Code
-
Cloud Save
-
Economy
-
Leaderboards
-
Lobby
-
Multiplay
-
Relay
-
Friends
-
Realm (closed beta)
-
RoamingDB (closed beta)
1 Like