Authentication via application launcher
If you use Xsolla Launcher or Steam to deliver your application to users, you can automatically authenticate the user using the launcher's credentials.
How-tos
You can use Xsolla Launcher to deliver your application to users and update it. The Launcher contains a built-in authorization tool. To avoid the need to re-enter username and password, set up authorization in your application via the Launcher.
Set up SDK and Launcher to work together
- Set up Launcher in your Publisher Account.
config.json
file, it is enough to change the values for the following objects:launcher_project_id
— specify Launcher ID found in Publisher Account > Launcher > General settings > General infologin_project_id
— specify Login ID found in Publisher Account > Launcher > General settings > Authentication
- Implement the Launcher authorization logic in your application.
- Generate a launcher installation file and a build archive.
- Create an application build.
- Upload the application build to the Xsolla update server.
Implement logic for authentication via Launcher
The flow for authorization in the application via Launcher is as follows:
- The user is authorized in Launcher.
- The user installs and runs the application.
- Launcher runs the application and passes user parameters via the command line. The authorization token is passed in the
xsolla-login-token
parameter. - The application processes command line parameters and obtains a token.
- The application validates the received token.
- The application automatically authorizes the user without displaying an authorization page.
To implement the described logic, use the AuthViaXsollaLauncher
SDK method.
Example of a script for authentication via Launcher:
- C#
using UnityEngine;
using Xsolla.Auth;
using Xsolla.Core;
namespace Xsolla.Samples.Authorization
{
public class AuthorizationViaXsollaLauncher : MonoBehaviour
{
private void Start()
{
// Start authorization via Xsolla Launcher
// Pass callback functions for success and error cases
XsollaAuth.AuthViaXsollaLauncher(OnSuccess, OnError);
}
private void OnSuccess()
{
Debug.Log("Authorization successful");
// Add actions taken in case of success
}
private void OnError(Error error)
{
Debug.LogError($"Authorization failed. Error: {error.errorMessage}");
// Add actions taken in case of error
}
}
}
Create an application build
- Go to your Unity project.
- Click
Window > Xsolla > Edit Settings in the main menu. In theInspector panel:- In the
Project ID field, specify the Project ID found in Publisher Account > Project settings > Project ID. - In the
Login ID field, specify the Login ID found in Publisher Account > Launcher > General settings > Authentication.
- In the
- Run the user authorization scene, where the token is processed.
- Click
File > Build settings in the main menu and then clickAdd Open Scenes . Make sure the authorization scene is added first in the list. - Click
Build . - In the pop-up window, specify the path to the directory where the finished build will be placed.
Was this article helpful?
Native authentication allows players to enter your application via the installed Steam application.
To set up native authentication:
- Set up silent authentication via Steam in Publisher Account.
- Configure your Unity project.
- Implement logic for authentication via Steam.
- Ensure authentication via Steam.
Configure your Unity project
Assets/Xsolla/ThirdParty/Steamworks.NET
directory.- Open the
steam_appid.txt
file, which is located in the root folder of the Unity project. - Specify your application ID in Steam in the file and save the changes. The default value in the file is
480
, which is the ID of the Steam test project. - Restart the Unity editor for the changes to take effect.
Implement logic for authentication via Steam
To start authentication, use the SilentAuth
SDK method and pass the following parameters to it:
providerName
— the application’s publishing platform. Passsteam
as a value.appId
— your application ID in Steam. The value must match the value specified in thesteam_appid.txt
file.sessionTicket
— Steam session ticket. To get it, call theSteamUtils.GetSteamSessionTicket()
method.onSuccess
— successful user authentication callback.onError
— error callback.
Example of a script for authentication via Steam:
- C#
using UnityEngine;
using Xsolla.Auth;
using Xsolla.Core;
namespace Xsolla.Samples.Steam
{
public class SteamNativeAuthorization : MonoBehaviour
{
private void Start()
{
// Get the steam session ticket from `SteamUtils` class
var steamSessionTicket = SteamUtils.GetSteamSessionTicket();
// Start silent authentication
// Pass `steam` as `providerName` parameter
// Pass your `Steam App ID` as `appId` parameter. We use `480` as an example
// Pass `steamSessionTicket` variable as the `sessionTicket` parameter
// Pass callback functions for success and error cases
XsollaAuth.SilentAuth("steam", "480", steamSessionTicket, OnSuccess, OnError);
}
private void OnSuccess()
{
Debug.Log("Authorization successful");
// Add actions taken in case of success
}
private void OnError(Error error)
{
Debug.LogError($"Authorization failed. Error: {error.errorMessage}");
// Add actions taken in case of error
}
}
}
Ensure authentication via Steam
- Launch Steam and log in. Otherwise, the callback function is called with the
Requested steam session ticket is null. Please check your Steam settings
error. - Create the build of your Unity project for a stand-alone platform and run it or start a scene in the Unity editor. If everything is correct, you are automatically logged into the applictaion.
Was this article helpful?
Found a typo or other text error? Select the text and press Ctrl+Enter.