question

tilutza avatar image
tilutza asked

Server side: get player entity from authentication token

Hello,

I have a token obtained from client with LoginWithCustomID. That token I want to send to the server to validate the player and to get his account profile.

I tried to use ValidateEntityTokenAsync but this throws an exception:

Message: PlayFab.PlayFabException : Must call GetEntityToken before calling this method

On the other side, GetEntityToken needs the entity id to obtain the token.

My question is the other way around. Having the authentication token, can I obtain the player entity?

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.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

Yes, you can pass the player entity token via ValidateEntityTokenAsync to get the player’s entity. I guess you use PlayFab C# SDK in your server code. If you want to use ValidateEntityTokenAsync API in a server program, please get the Title Entity Token before you call the ValidateEntityTokenAsync. Because only entities of title and cloud_root may call this API.

Yes, you can use GetEntityTokenAsync to get the title’s entity token. In this step, you need to provide the TitleId and Secret Key in the PlayFabSettings.staticSettings first, then call GetEntityTokenAsync. After you get the response of GetEntityTokenAsync successfully, the server program may call ValidateEntityTokenAsync API. It won’t throw such exceptions again.

10 |1200

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

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.