question

David McCarthy avatar image
David McCarthy asked

Authenticating a Server with an External API

Hi there,

I need my game servers to call an API which I am developing concurrently with the server. To authenticate those API calls I can see these options:

  1. Store API credentials as build-level environment variables i.e., an environment variable that applies to all servers for a particular build, whether they be active, on standby or yet to be created. I do not believe that PlayFab has this feature.
  2. Read API credentials from my Server.exe.config file. This is trivial to implement but has a major drawback: the build's lifetime is tied to the lifetime of those API credentials.
  3. Authenticate the Server using Playfab API calls.
  4. Something better/recommended that I have not thought of/come across.

Option 3 would look like this:

  • When a server is created, generate some unique ID for it and log in with LoginWithServerCustomId, creating a new Playfab user account for the server
  • Set a custom user ID string "trustMeI'maServer"
  • Include the server's session ticket in calls to my API
  • Have the API authoriser use AuthenticateSessionTicket to check that this call is being made from an account with the custom user ID string

I have 2 questions. Firstly, am I wrong about PlayFab not having build-level env vars? Secondly, is option 3 a good way to handle this?

Thanks!

AuthenticationCustom Game Servers
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

·
Rick Chen avatar image
Rick Chen answered

Do you mean the Multiplayer server? You were right, currently, PlayFab does not have the feature that stores build-level environment variables. If you would like this feature, you could post a thread in the Feature Request forum.

Yes, the option 3 you described sounds good. The AuthenticateSessionTicket API takes the PlayFab secret key in the header, please be careful and do not expose the secret key on your custom server.

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.