Hello,
I’m trying to write some leaderboard resets and such from my cloud code module using the AdminApiClient. However, the method parameters require service account keys and such. How can I access them from a cloudcode module?
For instance, the method below asks for the serviceAccountKey and serviceAccountSecret. Is there a way to pass this in or access it from the context?
GetLeaderboardVersionScoresPlayerRangeAsync(IExecutionContext executionContext, string serviceAccountKey, string serviceAccountSecret, Guid projectId, Guid environmentId, string leaderboardId, string versionId, string playerId, int? rangeLimit = null, CancellationToken cancellationToken = default(CancellationToken));
Hey! Here is a tutorial on how to create a service account and obtain these credentials: Service accounts
This is from Game Server Hosting. Therefore, one step will be different. Instead of adding a Multiplayer role in step 8, you will need to add a Leaderboards Admin project role. Then generate a key and those will be the required credentials.
Let me know if you run into any issues!
1 Like
Thanks, but I have that. I have a service account and keys. What I don’t know, is how I can obtain the key via api’s as opposes to storing it in my code somewhere. I.e. is there anyway we can access environment variables from our cloudcode module?
Thanks for clarifying. Unfortunately as of right now you would have to store those keys hardcoded into your Cloud Code module code. We are working on a secrets manager that would securely store and let you access your service account credentials.
1 Like
great, thank you.
Would you recommend hard coding them for now, or using a private game item to store and obtain them?
The easiest way would be to store it somewhere in the code if that module is the only one you are going to use for accessing the services. Otherwise you could explore putting that in Cloud Save.
1 Like