Steam login practical guide
Steam login is a feature that lets users log in to your app with their Steam account. Steam is an external authentication provider that authenticates users on the app's behalf, and the app gets a Hive Axyl login session from that authentication result. A session is the state in which login is complete and the Hive Axyl SDK identifies the user.
To implement it, you combine Steamworks settings, Hive Console settings, Hive Axyl SDK calls, recipe code calls, and app code. With the recipe code, the calls needed from getting credentials to activating the session come down to a single method.
Implementation scope
The work required to implement Steam login starts with preparing credentials in Steamworks and ends with displaying the screen that matches the login result.
The work in each step falls into one of the following six categories.
| Category | Owner | Description |
|---|---|---|
| External console | App operator | Settings you configure in Steamworks. |
| Hive Console | App operator | Settings you configure in the Hive Console. |
| Hive Axyl SDK | App developer | Hive Axyl SDK methods the app calls. |
| Add-on | App developer | The app directly calls methods of the Hive Axyl SDK extension package that handles Steam authentication. |
| Recipe code | App developer | Recipe methods the app calls. |
| App code | App developer | Parts the app implements directly without going through Hive Axyl. |
Steam login has no Hive Axyl Server API calls. The recipe makes most Add-on calls on the app's behalf, but on Windows and macOS there is one step in which the app calls the Add-on directly: releasing the authentication ticket after login is complete. For the meaning of the parameters and the response fields, see the detailed procedure linked in each step.
Recipe
The Hive Axyl SDK provides login features as fine-grained methods. The Add-on call that receives credentials from Steam, the method that logs in with those credentials, the method that issues tokens, and the method that activates the session are all separate. Even to log in a single user, the app must put together the call order and the handling of failures along the way by itself.
A recipe is source code that completes that combination in advance. Instead of installing it as a package, you copy it into your project.
| Category | Location | Characteristics |
|---|---|---|
| Hive Axyl SDK | Unity package com.com2usplatform.hiveaxyl.* | You install and use it. It provides authentication features as fine-grained methods. |
| Recipe | Assets/Recipes/ProviderLogin/, Assets/Recipes/ProviderLogin.Steam/, Assets/Recipes/ProviderLogin.WebAuth/ | You copy and use it. Plain C# code that groups SDK calls by purpose. |
| Usage example | Assets/RecipeExamples/Authentication/ProviderLoginExample.cs | Code you read for reference. Its comments explain the login flow common to all external authentication providers and the parts the app must implement for each result. |
Recipes are code you copy and use
Recipes are copied into your app and become your app's code. You can use them as is or modify them to fit your app's policies.
The login recipe is not tied to a single external authentication provider. ProviderLogin.Steam/ and ProviderLogin.WebAuth/ handle only the part that gets Steam credentials, and the rest of the process uses the same code as Apple or Google Play Games login.
OSs supported by the recipe
Because Steam login gets credentials differently depending on the OS, the recipe also provides two credential sources. A credential source is an object that receives the user identifier and the authentication result from Steam. The app selects the source that matches the OS it is running on and passes it to the recipe.
| Method | OS | Credential source | Authentication method |
|---|---|---|---|
| Steam client method | Windows, macOS | SteamCredentialSource | Receives an authentication ticket from the Steam client. The user is already logged in to the Steam client, so no separate login screen appears. |
| Browser-based method | Android, iOS | SteamOpenIdCredentialSource | Opens the Steam login page in a browser. The user logs in directly with their Steam account, and the login result returns to the app through the relay URL that Hive Axyl operates. |
This guide uses the names above to distinguish the two methods. The two sources differ only in the values they receive, and the rest of the process is the same. Whichever one you use, you call the recipe and handle the results in the same way.
Each source works only in environments where the required Add-on is registered. If you call it in an environment where the Add-on is not registered, it returns an Unavailable error. This does not mean that the login was rejected; it means that Steam login cannot run in that environment. Neither Add-on is registered in the Unity Editor.
What the app implements
The recipe handles only the steps from getting credentials to activating the session on the app's behalf. The app implements the following items outside the recipe.
- The login screen and the screen transition after login
- The branch that selects the credential source for the OS the app is running on
- For the Steam client method, Steamworks initialization and callback handling, reading the Steam ID64, and releasing the authentication ticket
- For the browser-based method, building the URL that Steam sends the user back to and registering the app callback scheme on Android
- Creating and storing
DeviceKey - Storing the session token received from login
- The retry policy and user-facing messages when a failure occurs
Common prerequisites
Before you start implementing, prepare the following items.
| Item to prepare | Required | Category | Where to check |
|---|---|---|---|
| Check the Steam App ID | Required | External console | Register the store App ID |
| Create a project | Required | Hive Console | Create a project |
| Create an App ID | Required | Hive Console | Create an App ID |
| Register the Store App ID | Required | Hive Console | Register the store App ID |
| Check the Client ID | Required | Hive Console | Get the security key |
| Connect the SDK to your Unity project | Required | Hive Axyl SDK | Connect the SDK to your Unity project |
An App ID is created from a combination of runtime environment and store. For Windows or macOS builds distributed on Steam, select Steam as the store and enter the Steam App ID you checked in Steamworks in Store App ID. If you also offer Android and iOS builds, create separate App IDs for those combinations. You enter the App ID when you initialize the SDK and the Client ID when you log in, so check both first. Connect the SDK first so that you can install the authentication module and the Add-on in the following steps.
Next steps
Once you have completed the prerequisites, start Implement Steam login.