In-game user authentication
How it works
Launcher sends the data of the users, authenticated via the desktop app, to the game in the –xsolla-login-token
parameter in the JWT format. You can use this parameter to set up automatic in-game user authentication.
Main JWT claims
A token will contain the main claims after authentication or email address confirmation. Presence of these claims does not depend on the user database and authentication call.
Claim | Type | Required | Description |
---|---|---|---|
exp | Unix Timestamp | Yes | Date and time of token expiration. Default expiration time is 24 hours. You can change expiration time for every Login project. |
iss | string | Yes | Service that signed the token: https://login.xsolla.com . |
iat | Unix Timestamp | Yes | Date and time of giving the token. |
sub | string (UUID) | Yes | User ID written on the Xsolla Login server side. |
groups | array | Yes | The list of groups the user is in. Every group is written in the following format:
|
xsolla_login_project_id | string (UUID) | Yes | Login project ID. |
username | string | Username. | |
publisher_id | integer | ID of a merchant who owns a Login project. | |
email | string | User email address. | |
payload | string | Additional information that is passed in the payload parameter during authentication. | |
promo_email_agreement | boolean | Consent to receive a newsletter. May have one of the following values:
true value by default.To add the feature to the registration form of the Login widget:
| |
connection_information | string | Shows whether the user confirmed their birth date or not. Confirmation is made via the okname service. |
Social authentication
Claims that are contained in the token after authentication via a social network. Presence of these claims does not depend on the user database.
Claim | Type | Required | Description |
---|---|---|---|
provider | string | Yes | Name of a social network used for authentication. Possible values: amazon , apple , baidu , battlenet , discord , facebook , github , google , kakao , linkedin , mailru , microsoft , msn , naver , ok , paypal , psn , qq , reddit , steam , twitch , twitter , vimeo , vk , wechat , weibo , yahoo , yandex , youtube , xbox . |
id | string | Yes | User ID in a social network. |
is_cross_auth | boolean | Shows that the silent authentication request is in progress. | |
social_access_token | string | Social network account access_token parameter used for authentication. Contact your Customer Success Manager or email to csm@xsolla.com to set up the feature | |
picture | string (URL) | Link to the user profile picture in a social network. | |
birthday | date (RFC 3339) | User birth date in a social network. | |
gender | string | User gender in a social network. | |
name | string | User nickname in a social network. |
User flow
- A user logs in to the launcher.
- The launcher receives the authorization token with the user information from the Xsolla Login server.
- The user starts the game from the launcher.
- When launching the game, the launcher passes the following arguments to the game client:
--xsolla-login-token <token>
— the authorization token obtained from the Xsolla Login server.--xsolla-locale <locale>
— UI language.
Example:
game.exe --xsolla-login-token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6InAudHVnb2x1a292QHhzb2xsYS5jb20iLCJleHAiOjE1ODU1MDYxMTMsImdyb3VwcyI6W10sImlhdCI6MTU4NDY0MjExMywiaXNzIjoiaHR0cHM6Ly9sb2dpbi54c29sbGEuY29tIiwicGFydG5lcl9kYXRhIjp7ImFkbWluIjp0cnVlfSwicGF5bG9hZCI6IiIsInByb21vX2VtYWlsX2FncmVlbWVudCI6dHJ1ZSwicHJvdmlkZXIiOiJ4c29sbGEiLCJyZWRpcmVjdF91cmwiOiIiLCJzdWIiOiIyNmYxNzI5Ni00Nzk5LTExZTgtOTBkMC00MjAxMGE4YTAwMTkiLCJ0eXBlIjoic29jaWFsIiwidXNlcm5hbWUiOiJzb21lX3VzZXJAbWFpbC5jb20iLCJ4c29sbGFfbG9naW5fYWNjZXNzX2tleSI6Ikk2QTJrTEZPQ2JkcnUzamIxMjNyT3JmWnNkTnFpdVcxMjNpWTdKcW85OHI5b0hPbyIsInhzb2xsYV9sb2dpbl9wcm9qZWN0X2lkIjoiNDBkYjJlYTQtNWQ0Mi0xMWU2LWEzZmYtMDA1NDU2YTBlMTRhIn0.ZsTNiwY2iPp7HKqHs5g6JXzL2kv_RVuMNBlF-Tn2ccE --xsolla-locale en
- The game client sends the obtained user token to the game server to retrieve user data in one of the following ways:
How to get it
- Implement the retrieval of user data:
- Set up parameter processing for the game to authenticate users automatically.
- Implement the selection of the interface language based on the language obtained in the argument
--xsolla-locale <locale>
on the game client. - Implement tracking of new users and creation of their accounts on the game server.
Decoding JWT on the game server
- Open your project in Publisher Account and go to the Login section.
- Click Configure in the pane of a Login project.
- Go to the Security block and select the JWT signature section.
- Сopy the value of the Secret key field.
- Choose the library and connect it on the server side of your application.
- Pass the value copied in the step 4 to the decoding function entry.
User data retrieval using Login API
Call the Get user details Login API method to retrieve user data.
User registration
To track the registration of new users:
- Open your project in Publisher Account and go to the Login section.
- Click Configure in the pane of a Login project.
- In the top settings block, click Callback URLs.
- In the Callback URL field, enter the URL address to which the user should be redirected after registration.
- Configure the creation of a new account in the game. After registration, the user will be redirected to the URL specified in the Callback URL field with the parameter
is_new=1
. - To obtain information for filling in the account, use the Login API method.
Example:
https://<callbackUrl>?is_new=1&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWR
UI language
Example | Value | Meaning |
---|---|---|
–xsolla-locale en | “en”“ru”“cn”“tw”“fr”“de”“it”“pt”“es”“pl”“cs”“ko”“ar”“bg”“he”“ja”“tr”“th”“vi”“ro” | “English”“Русский”“简体中文”“中国传统的”“Français”“Deutsch”“Italiano”“Português”“Español”“Polski”“Čeština”“한국어”“العربية”“Български”“עברית”“日本語”“Türkçe”“ไทย”“Tiếng Việt”“Română” |
Found a typo or other text error? Select the text and press Ctrl+Enter.