question

Mojo avatar image
Mojo asked

Healess server access to playfab

Hello there,

I have a headless server and I want it to "login" to playfab to retrieve global information and players information, what is the best way to do that?
Do I have for each server session to create a playfab user? Or just one user for all of them?

Or is there a way to access playfab info without creating a user?

Thanks.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image
Seth Du answered

You may directly call Server API, where only Secret key will be required. It won’t be necessary to “login” into any actual account. Please refer to the Server section of the documentation: https://docs.microsoft.com/en-us/gaming/playfab/api-references/

Please note that in terms of Entity APIs, you need to call GetEntityToken, to use Secret Key in the http request header to get a title-level Entity Token to perform Server-Level performance.

You may craft your own command line tools with any of the SDK provided on our website: https://docs.microsoft.com/en-us/gaming/playfab/index#pivot=documentation&panel=sdks.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Mojo avatar image
Mojo answered

Hi SethDu,

thanks for your reply.

I'm using right now "old" playfab API, not sure how the entities stuff work.
Anyway, I'm trying in Unity to create a server, which will have to use serverAPI.

From what I understand in your reply , I don't have to login, as I have to for a client, I can skip this step.

Then I tried to call PlayFabServerAPI.ExecuteCloudScript, but there is no secretKey in the request parameters, but there is a playerId field(???).

What did I miss?

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

Yes, if you are using Unity, you can define the secret key in the Unity PlayFab Extension and extension will generate configuration files automatically, otherwise, you can set it via the code:

PlayFabSettings.DeveloperSecretKey

In terms of Entity token, you may use:

PlayFabSettings.staticPlayer.EntityToken

It is not a part of request because it is used for verification. As long as you are using Server API, you will be considered as an administrator of the title and you need to add the player ID in the request as the target player where your performance takes effects.

0 Likes 0 ·
Mojo avatar image
Mojo answered

ok, I'll give that a try.

But I have 2 more concerns :
First the dev secret key is not the same in UnityPlayfabExtension and in playfab dashboard TitleSettings/SecretKey

Second, am I obliged to have a playfabId with Server/ExecuteCloudScript? I was planning to send all playerIds to cloudscript to treat them all there instead of sending one by one.

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

1. May I ask what does it mean by not the same? All the keys available for your title should be displayed in the Title Setting.

2. If you have a task that need to retrieve information from plenty of players, Cloud Script will exceed the runtime limit. A dedicated external server will be needed. Besides, you can also consider using Scheduled Tasks to apply the actions to all members of a segement.

0 Likes 0 ·
Mojo avatar image
Mojo answered

1/ The secret key value in playfab dashboard is not the same as in unity "playfab edEx/Settings/dev Secret key".

2/ If I just want to get title data for the server, I cannot do it without using a client ID, I cannot have access to the game data if I have no player?

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

1. It is strange, does Server API work? Do you set the same Title ID? In addition, have you configured more than one key?

2. If it is title Data, you don't need a player ID. For more information, please always refer to the API documentation, and If Player ID is necessary, there will be "required" marked for this property.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.