Appearance
Appearance
You can use Steam to authenticate users when the player logins to the game server, automatically connecting their Steam account to their Metaplay account and sharing progression with other devices that run your game through Steam.
To use Steam sign-in, you need to:
Create a Steam WebApi key.
Follow instructions at https://partner.steamgames.com/doc/webapi_overview/auth#create_publisher_key.
Configure the game server to accept and validate Steam sign-in requests.
In the relevant Options.<env>.yaml
, set:
Steam:
EnableSteam: true
PublisherAuthenticationKeyPath: [The Steam publisher authentication key created in step 1]
💡 Pro tip
We recommend using the AWS secret manager to store any sensitive secrets. See AWS Secrets Manager for more information!
Install Steamworks.net
Follow instructions at https://steamworks.github.io/installation/.
📌 Note
If you choose to do "Manual Installation", please set the METAPLAY_HAS_STEAMWORKS
define in the "Windows, Mac, Linux settings" in the Unity Project Settings.
Invoke Steam's RunCallbacks
Add a call to SteamAPI.RunCallbacks()
in your update.
Define a custom MetaplayConnectionDelegate
Create a new class GameConnectionDelegate
and inherit from DefaultMetaplayConnectionDelegate
.
class GameConnectionDelegate : DefaultMetaplayConnectionDelegate
{
public override ISessionCredentialService GetSessionCredentialService()
{
// Choose Steam if we are on the right platform and Steam is enabled
#if UNITY_STANDALONE && METAPLAY_HAS_STEAMWORKS
return new SteamCredentialService();
#else
// Otherwise, fallback to default behaviour
return base.GetSessionCredentialService();
#endif
}
}
Use the new connection delegate in MetaplayClient
In your initialization code for MetaplayClient, set the MetaplayClientOptions.ConnectionDelegate
to your new GameConnectionDelegate
// Initialize Metaplay SDK.
MetaplayClient.Initialize(new MetaplayClientOptions
{
...
// Use your newly defined connection delegate.
ConnectionDelegate = new GameConnectionDelegate(),
...
});
Your users should now be able to login with Steam. If you take a look at your player's profile in the dashboard, you should see Steam as a login method under the Account Access & Logs tab.