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                                                  TypeRequiredDescription
expUnix TimestampYesDate and time of token expiration. Default expiration time is 24 hours. You can change expiration time for every Login project.
issstringYesService that signed the token: https://login.xsolla.com.
iatUnix TimestampYesDate and time of giving the token.
substring (UUID)YesUser ID written on the Xsolla Login server side.
groupsarrayYesThe list of groups the user is in. Every group is written in the following format:
  • id — group ID;
  • name — group name;
  • is_default — shows whether the group is default or not (true or false).
There can be only one default group. This group initially includes all users before they are distributed into different groups.
xsolla_login_project_idstring (UUID)YesLogin project ID.
usernamestringUsername.
publisher_idintegerID of a merchant who owns a Login project.
emailstringUser email address.
payloadstringAdditional information that is passed in the payload parameter during authentication.
promo_email_agreementbooleanConsent to receive a newsletter. May have one of the following values:
  • true if the user agrees to receive a newsletter.
  • false otherwise.
Has the true value by default.
To add the feature to the registration form of the Login widget:
  • Contact your Customer Success Manager or email to csm@xsolla.com if you use Widget 2.0.
  • Add the fields parameter with the promo_email_agreement value to the initialization code if you use the previous version of the widget.
connection_informationstringShows 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                                                  TypeRequiredDescription
providerstringYesName 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.
idstringYesUser ID in a social network.
is_cross_authbooleanShows that the silent authentication request is in progress.
social_access_tokenstringSocial network account access_token parameter used for authentication. Contact your Customer Success Manager or email to csm@xsolla.com to set up the feature
picturestring (URL)Link to the user profile picture in a social network.
birthdaydate (RFC 3339)User birth date in a social network.
genderstringUser gender in a social network.
namestringUser nickname in a social network.

User flow

  1. A user logs in to the launcher.
  2. The launcher receives the authorization token with the user information from the Xsolla Login server.
  3. The user starts the game from the launcher.
  4. 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:

Copy
Full screen
Small screen
    game.exe --xsolla-login-token eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6InAudHVnb2x1a292QHhzb2xsYS5jb20iLCJleHAiOjE1ODU1MDYxMTMsImdyb3VwcyI6W10sImlhdCI6MTU4NDY0MjExMywiaXNzIjoiaHR0cHM6Ly9sb2dpbi54c29sbGEuY29tIiwicGFydG5lcl9kYXRhIjp7ImFkbWluIjp0cnVlfSwicGF5bG9hZCI6IiIsInByb21vX2VtYWlsX2FncmVlbWVudCI6dHJ1ZSwicHJvdmlkZXIiOiJ4c29sbGEiLCJyZWRpcmVjdF91cmwiOiIiLCJzdWIiOiIyNmYxNzI5Ni00Nzk5LTExZTgtOTBkMC00MjAxMGE4YTAwMTkiLCJ0eXBlIjoic29jaWFsIiwidXNlcm5hbWUiOiJzb21lX3VzZXJAbWFpbC5jb20iLCJ4c29sbGFfbG9naW5fYWNjZXNzX2tleSI6Ikk2QTJrTEZPQ2JkcnUzamIxMjNyT3JmWnNkTnFpdVcxMjNpWTdKcW85OHI5b0hPbyIsInhzb2xsYV9sb2dpbl9wcm9qZWN0X2lkIjoiNDBkYjJlYTQtNWQ0Mi0xMWU2LWEzZmYtMDA1NDU2YTBlMTRhIn0.ZsTNiwY2iPp7HKqHs5g6JXzL2kv_RVuMNBlF-Tn2ccE --xsolla-locale en
    
    1. 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

    1. Implement the retrieval of user data:
    2. Set up parameter processing for the game to authenticate users automatically.
    3. Implement the selection of the interface language based on the language obtained in the argument --xsolla-locale <locale> on the game client.
    4. Implement tracking of new users and creation of their accounts on the game server.

    Decoding JWT on the game server

    1. Open your project in Publisher Account and go to the Login section.
    2. Click Configure in the pane of a Login project.
    3. Go to the Security block and select the JWT signature section.
    4. Сopy the value of the Secret key field.
    5. Choose the library and connect it on the server side of your application.
    6. Pass the value copied in the step 4 to the decoding function entry.
    Notice
    Do not reveal your secret key to anyone. If it was compromised, please update it.

    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:

    1. Open your project in Publisher Account and go to the Login section.
    2. Click Configure in the pane of a Login project.
    3. In the top settings block, click Callback URLs.
    4. In the Callback URL field, enter the URL address to which the user should be redirected after registration.
    5. 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.
    6. To obtain information for filling in the account, use the Login API method.

    Example:

    Copy
    Full screen
    Small screen
      https://<callbackUrl>?is_new=1&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiYWR
      

      UI language

      ExampleValueMeaning
      –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ă”
      Was this article helpful?
      Thank you!
      Is there anything we can improve? Message
      We’re sorry to hear that
      Please explain why this article wasn’t helpful to you. Message
      Thank you for your feedback!
      We’ll review your message and use it to help us improve your experience.
      Last updated: September 23, 2024

      Found a typo or other text error? Select the text and press Ctrl+Enter.

      Report a problem
      We always review our content. Your feedback helps us improve it.
      Provide an email so we can follow up
      Thank you for your feedback!