Autenticación

Learn about advanced setups from our how-tos.

Cómo establecer la autenticación de OAuth 2.0

OAuth 2.0 uses short-lived tokens with long-term authorization (refresh tokens) instead of long-lived tokens. A refresh token allows users to stay in your application for an extended period of time without needing to re-enter their username and password. This eliminates the risk of compromising user authentication data.

Set up OAuth 2.0 for authorization:

  • via username or email and password
  • via social networks
  • via Steam

If the option is enabled, user registration and authentication is carried out by calling the Register new user and JWT auth by username and password API calls. The Login & Account System plug-in provides the same methods for OAuth 2.0 authorization as for JWT token authorization. In the FXsollaAuthToken structure, the refresh token is specified in the RefreshToken field.

Nota
Enabling this setting doesn’t change the authentication process in your application for the user.

To configure OAuth 2.0 authorization:

  1. Set up OAuth 2.0 authentication for Login project in your Publisher Account.
  2. Set up plug-in in your UE4 project.

Configure la autenticación OAuth 2.0 para el proyecto de Inicio de sesión (Login) en su Cuenta del editor

  1. Go to your Publisher Account.
  2. Click Login in the side menu.
  3. Click Configure in the Login project pane.
  4. Go to the Security block and select the OAuth 2.0 section.
  5. Click Add OAuth 2.0.
  6. Specify OAuth 2.0 redirect URIs and click Connect.
  7. Copy and save the Client ID.

Configurar el complemento en su proyecto de Unreal Engine

  1. Open your UE4 project in Unreal Editor.
  2. Go to Settings > Project Settings > Plugins > Xsolla Login.
  3. Enable Use OAuth 2.0 option.
  4. In the Client ID field, specify Client ID received when setting up OAuth 2.0 in Publisher Account.

The following methods are implemented in Login & Account System plug-in to work with refresh tokens:

  • RefreshToken — refreshes the token if it has expired.
  • ExchangeAuthenticationCodeToToken — exchanges the user’s authentication code for a valid JWT.

The State parameter found in the RegisterUser, GetSocialAuthenticationUrl, and AuthenticateWithSessionTicket methods is used for additional user verification during OAuth 2.0 authentication. This parameter is used to mitigate possible CSRF attacks.

¿Te ha resultado útil este artículo?
¡Gracias!
¿Hay algo en lo que podamos mejorar? Mensaje
Lo sentimos
Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
¡Gracias por tu mensaje!
Nos ayudará a mejorar tu experiencia.
Ocultar

Cómo utilizar su propio sistema de autorización

Aviso

Use this how-to when working only with the following plug-ins:

  • Game Commerce
  • Cross-Buy

The Cross-Buy plug-in will be deprecated in March 2022. You can continue to use it, but it will not be updated and supplemented with new features. It is recommended to switch to the Game Commerce plug-in. It contains all the classes and methods needed to work with Xsolla products.

You can integrate the SDK with your own authorization system. To do this, implement user identification by custom ID (user ID generated on your server) to open an in-game store, make a payment, and manage inventory.

The flow of interaction with Xsolla servers when using your own authorization system:

  1. Your client sends an authentication request to your server.
  2. Your server authorizes the user and sends a request to the Xsolla server to receive the user JSON Web Token (JWT), passing in the custom ID.
  3. Xsolla server returns the user JWT.
  4. Your server passes the user JWT to the client.
  5. SDK methods use the received user JWT instead of authorization token to open an in-game store, make a payment, and manage inventory.

To use your own authorization system with Xsolla products:

  1. Set up server OAuth 2.0 client in your Publisher Account.
  2. Implement getting the server JWT.
  3. Implement getting the user JWT.
  4. Implement the logic of working with the in-game store, purchases, and inventory using the user JWT.

Nota
If you use the PlayFab or Firebase authorization system, get the user JWT using Xsolla ready-made extensions for BaaS.

Establecer el cliente de OAuth 2.0

  1. Open your project in Publisher Account and go to the Login section.
  2. Click Configure in the panel of a Login project.
  3. Go to the Security block and select the OAuth 2.0 section.
  4. Click Add OAuth 2.0.
  5. Specify OAuth 2.0 redirect URIs.
  6. Check the Confidential (recommended for server-to-server connection) box.
  7. Click Connect.
  8. Copy and save the client ID and secret key.

Obtener el JWT del servidor

On the back end of your application, implement a method to get the server JWT using the Generate JWT API call. The request must contain the following parameters:

Nota
The server JWT lifetime is 59 minutes.

Obtener el JWT de usuario

On the back end of your application, implement a method to get the user JWT using the Auth by custom ID API call. The request must contain the X-Server-Authorization: <server_JWT> header, where <server_JWT> is the server JWT obtained in the previous step.

Nota
The user JWT lifetime is 24 hours. To change it, contact your Account Manager or email integration@xsolla.com.

Utilizar el JWT de usuario

Use the SDK methods to open the in-game store, make a payment, and manage inventory. While using the SDK methods, pass the user JWT instead of authorization token.

The following tutorials contain examples of using the token:

Implement the logic of receiving a new user JWT after its expiration. It is recommended that you get a new token in the background mode, so the user doesn’t have to log in to the application again.

¿Te ha resultado útil este artículo?
¡Gracias!
¿Hay algo en lo que podamos mejorar? Mensaje
Lo sentimos
Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
¡Gracias por tu mensaje!
Nos ayudará a mejorar tu experiencia.
Ocultar

Cómo establecer la autenticación nativa a través de redes sociales

Native authentication allows players to log in to your application via installed applications that use social network accounts. Currently, SDK has implemented native authentication via the following social networks:

  • Google
  • Facebook

Nota
Native authentication via social networks is available in:
  • Game Commerce plug-in version 0.5.7 and higher for UE4
  • Login & Account System plug-in version 0.3.0 and higher for UE4
  • Cross-Buy plug-in version 0.3.0 and higher for UE4

To configure native authentication:

  1. Create your UE4 project build for Android.

Nota
For further native authentication configuration you will need the package name of your Android application found in the Edit > Project Settings > Platforms > Android section in the Android Package Name (‘com.YourCompany.Project’ [PROJECT] is replaced with project name) field.
  1. Set up authentication via social networks on the Xsolla side:
    1. For Facebook and Google, set up social connections in Publisher Account.
    2. For WeChat and QQ, contact your Customer Success Manager or email to csm@xsolla.com.
  2. Set up the SDK for your Unreal Engine project.
  3. Implement authentication logic on the application side.

Establezca la página de la aplicación en su cuenta de desarrollador de Facebook

  1. Go to project settings in the Facebook developer account.
  2. Go to Settings > Basic.
  3. Click Add Platform and select Android.
  4. Specify the package name of your Android application in the Google Play Package Name field.
  5. Specify a fully qualified class name of the Activity in the Class Name field (default value is com.epicgames.ue4.GameActivity).
  6. Generate a hash key and specify it in the Key Hashes field.
  7. Click Save Changes.

For further native authentication configuration, you will need App ID and App Secret found in project settings in Settings > Basic section.

Configurar un proyecto en Google API Console

  1. Go to Google API Console.
  2. Click New Project.
  3. Specify Project name and Location and click Save.
  4. Go to the created project and click OAuth consent screen in the side menu.
  5. Select External option and click Create.
  6. Specify the necessary parameters and click Save.
  7. Click Credentials in the side menu.
  8. Create an OAuth 2.0 client for your Android app:
    1. Click Create credentials and select OAuth client ID.
    2. Specify Android in the Application type field.
    3. Specify Name.
    4. Specify package name of your Android application in the Package name field.
    5. Get the SHA-key.
    6. Specify SHA-key generated in the previous step SHA-key in the SHA-1 certificate fingerprint field.
    7. Click Create.
    8. Click OK.
  1. Create an OAuth 2.0 client for the web application:
    1. Click Create credentials and select OAuth client ID.
    2. Specify Web application in the Application type field.
    3. Specify Name.
    4. Click Add URI in the Authorized redirect URIs section and specify https://login.xsolla.com/api/social/oauth2/callback URI.
    5. Click Create.
    6. Click OK.

For further native authentication configuration, you will need Client ID and Client Secret found in settings of the Client ID for the web application.

Establecer las conexiones de redes sociales para el proyecto de Login en Cuenta del editor de Xsolla

  1. Open your project in Publisher Account.
  2. Click Login in the side menu and go to Login projects > your Login project > Social connections.
  3. To set up authentication via Facebook:
    1. Click Edit in the Facebook panel and change status to Disconnected.
    2. Specify the App ID from the Facebook developer account in the Application ID field.
    3. Specify App Secret from the Facebook developer account in the Application Secret field.
    4. Click Connect.
  1. To set up authentication via Google:
    1. Click Edit in the Google panel and change status to Disconnected.
    2. Specify the Client ID for a web application from the Google API Console in the Application ID field.
    3. Specify the Client Secret for a web application from the Google API Console in the Application Secret field.
    4. Click Connect.

Configurar el SDK para un proyecto de Unreal Engine

  1. Go to your UE4 project.
  2. Go to Settings > Project Settings > Plugins > Xsolla Login > Xsolla Login Android.
  3. Check the Allow Native Auth box.
  4. Specify App ID from the Facebook developer in the Facebook App Id field.
  5. Specify the Client ID for a web application from the Google API Console in the Google App Id field.
¿Te ha resultado útil este artículo?
¡Gracias!
¿Hay algo en lo que podamos mejorar? Mensaje
Lo sentimos
Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
¡Gracias por tu mensaje!
Nos ayudará a mejorar tu experiencia.
Ocultar

Cómo configurar la autenticación nativa a través de Steam

Native authentication allows players to enter your application via the installed Steam client. After setting up native authentication via Steam, you can also add payment via Steam to the application.

To set up native authentication:

  1. Set up silent authentication via Steam in Publisher Account.
  2. Configure your UE4 project.
  3. Configure the processing of events.
  4. Ensure authentication via Steam.

Configure su proyecto de Unreal Engine

  1. Go to the Config catalog of your UE4 project.
  2. Add the lines below to the DefaultEngine.ini file and specify your app ID in Steam for the SteamDevAppId parameter.
Copy
Full screen
Small screen
    [/Script/Engine.GameEngine]
    +NetDriverDefinitions=(DefName="GameNetDriver",DriverClassName="OnlineSubsystemSteam.SteamNetDriver",DriverClassNameFallback="OnlineSubsystemUtils.IpNetDriver")
    
    [OnlineSubsystem]
    DefaultPlatformService=Steam
    
    [OnlineSubsystemSteam]
    bEnabled=true
    SteamDevAppId=480
    
    [/Script/OnlineSubsystemSteam.SteamNetDriver]
    NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection"
    
    1. Open the project in the Unreal Editor.
    2. Go to Settings > Plugins > Online Platform.
    3. In the Online Subsystem Steam module, check the Enabled box and click the Restart Now button to save settings and reload the Unreal Editor.

    Configurar el procesamiento de los eventos

    1. The image below shows how to add nodes to the project:
      To authenticate users via Steam, you should get a session ticket via the GetSessionTicket method. Pass the received value when calling the AuthenticateWithSessionTicket method. As a result, you get the token that is used when calling the API.
    1. For additional token validation, add the ValidateToken method callback (optional).

    Garantizar la autenticación a través de Steam

    1. Create the build of your UE4 project for a stand-alone platform.
    2. Launch Steam and log in.
    3. Launch your application. If everything is correct, the Steam pop-up window appears.
    ¿Te ha resultado útil este artículo?
    ¡Gracias!
    ¿Hay algo en lo que podamos mejorar? Mensaje
    Lo sentimos
    Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
    ¡Gracias por tu mensaje!
    Nos ayudará a mejorar tu experiencia.
    Ocultar

    Cómo configurar la invalidación de tókenes

    Token invalidation allows for improved security of user authentication data in your application. If the option is enabled, a new token replaces the old one that becomes invalid every time the user authenticates.

    Nota
    You can configure token invalidation for authentication that uses a JWT token. For OAuth 2.0 authentication, token invalidation is provided by the protocol itself and does not need to be configured separately.

    When using the SDK, invalidation of the existing token and generation of a new one is made by calling Auth by username and password and Auth via social network API calls, if the with_logout parameter has the 1 value.

    To enable token invalidation in your UE4 project:

    1. Go to Settings > Project Settings > Plugins > Xsolla Login.
    2. Enable the Invalidate Existing Sessions option.

    ¿Te ha resultado útil este artículo?
    ¡Gracias!
    ¿Hay algo en lo que podamos mejorar? Mensaje
    Lo sentimos
    Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
    ¡Gracias por tu mensaje!
    Nos ayudará a mejorar tu experiencia.
    Ocultar

    Cómo establecer la autorización en la aplicación mediante Launcher

    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.

    Aviso
    To use the Launcher, you need to configure Login. Using a different authorization system is not supported.

    Configurar el SDK y Launcher para que funcionen juntos

    1. Set up Launcher in your Publisher Account.
    Nota
    In the 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 info
    • login_project_id — specify Login ID found in Publisher Account > Launcher > General settings > Authentication
    1. Customize the launcher UI.
    Aviso
    SDKs integration with Xsolla servers uses Commerce API calls, so the Launcher store is not supported.
    1. Implement the Launcher authorization logic in your application.
    2. Generate a launcher installation file and a build archive.
    3. Create an application build.
    4. Upload the application build to the Xsolla update server.

    Implementar la lógica para la autorización mediante el Lanzador

    The flow for authorization in the application via Launcher is as follows:

    1. The user is authorized in the Launcher.
    2. The user installs and runs the application.
    3. Launcher runs the application and passes user parameters via the command line. The authorization token is passed in the xsolla-login-token parameter.
    4. The application processes command line parameters and obtains a token.
    5. The application validates the received token.
    6. The application automatically authorizes the user without displaying an authorization page.

    An example of the implementation of this logic is available in the W_LoginDemo blueprint of the demo project.

    Nota
    The obtained token is used by SDK methods to open an in-game store, make a payment, etc.

    Crear una compilación de la aplicación

    1. Go to your UE4 project.
    2. In the Content Browser, open the user authorization map where the token is being processed.
    3. Go to Edit > Project Settings in the main menu.
    4. Go to Project> Maps & Modes and in the Game Default Map field select the previously opened authorization map.
    1. Go to Plugins > Xsolla Login.
    2. In the Project ID field, specify the Project ID found in Publisher Account > Project settings > Project ID.
    3. In the Login ID field, specify the Login ID found in Publisher Account > Launcher > General settings > Authentication.
    4. Go to File > Package Project > Windows (64 bit) or to File > Package Project > Mac in the main menu, depending on the platform for which you are creating the build.
    5. In the pop-up window, specify the path to the directory where the finished build will be placed.
    ¿Te ha resultado útil este artículo?
    ¡Gracias!
    ¿Hay algo en lo que podamos mejorar? Mensaje
    Lo sentimos
    Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
    ¡Gracias por tu mensaje!
    Nos ayudará a mejorar tu experiencia.
    Ocultar

    Cómo implementar la autenticación de usuario mediante ID del dispositivo

    Device ID authentication lets users start using the application on a mobile device without entering registration data. The first time a user logs in to the application using the device ID, a new account is created automatically, and the user doesn’t need to enter a username, email address, or other data.

    Aviso
    The account created by the device ID allows using the application only on the current mobile device. Access to it is lost after changing an Android or iOS device or after uninstalling an application on an iOS device. To save progress in the application and use the account on other devices, the user can upgrade the account by linking a social network or by entering a username, email address, and password.

    With the device ID, you can implement user authentication on one or more mobile devices in the background mode. To use this function, the user should link the device ID to an existing account.

    The SDK supports authentication via ID of mobile devices on Android and iOS.

    Obtener ID de dispositivo

    The device ID is generated by the platform and is available to applications installed on the mobile device. The SDK gets the ID value using the platform API and uses this value to perform various functions using the Xsolla API.

    The iOS device ID is passed in the UIDevice.identifierForVendor property. The Android device ID is passed in the android.provider.Settings.Secure.ANDROID_ID constant. The standard UE4 Get Device Id method is used to determine the ID.

    Métodos del SDK

    The SDK implements methods for the following functions:

    Autenticación

    SDK method nameDescription
    AuthenticateViaDeviceId
    Authenticates the user to the application using the current device ID.

    Actualización de cuenta

    SDK method nameDescription
    LinkEmailAndPassword
    Adds a username, email address, and password, that can be used for authentication, to the current account.
    LinkSocialNetworkToUserAccount
    Links a social network, that can be used for authentication, to the current account.
    Aviso
    The listed methods can be used to upgrade an account created in any available way (e.g. by using a social network or an email address and password).

    Administración de dispositivos

    SDK method nameDescription
    UpdateUsersDevices
    Returns a list of devices linked to the current user account.
    LinkDeviceToAccount
    Links the specified device to the current user account.
    UnlinkDeviceFromAccount
    Unlinks the specified device from the current user account.
    ¿Te ha resultado útil este artículo?
    ¡Gracias!
    ¿Hay algo en lo que podamos mejorar? Mensaje
    Lo sentimos
    Por favor, cuéntanos por qué no te ha resultado útil este artículo. Mensaje
    ¡Gracias por tu mensaje!
    Nos ayudará a mejorar tu experiencia.
    Ocultar
    Última actualización: 22 de Enero de 2024

    ¿Has encontrado una errata u otro error de texto? Selecciona el texto y pulsa Ctrl+Intro.

    Informar de un problema
    Nos esforzamos por ofrecer contenido de calidad. Tus comentarios nos ayudan a mejorar.
    Déjanos tu correo electrónico para que te podamos responder
    ¡Gracias por tu mensaje!