How to integrate user authentication via Xsolla account

How it works

You can add user authentication with Xsolla account on Xsolla Wallet.

Note
The above image shows one of the options for the login widget. You can customize the widget.

User scenarios

You can implement one of the following user scenarios:

  1. Opening the Xsolla Wallet authentication page in a modal window by clicking the Log in with Xsolla button in the login widget:
    1. The user clicks the Log in with Xsolla button in the login widget.
    2. They are redirected to the Xsolla Wallet authentication screen that opens in a modal window.
    3. The user completes the authentication process on Xsolla Wallet.
    4. They are redirected to the page whose URL is specified in the Callback URL field in Publisher Account.

  1. Redirecting to the Xsolla Wallet authentication page by clicking the Log in with Xsolla button in the login widget:
    1. The user clicks the Log in with Xsolla button in the login widget.
    2. They are redirected to the Xsolla Wallet authentication screen that opens in the same window.
    3. The user completes the authentication process on Xsolla Wallet.
    4. They are redirected to the page whose URL is specified in the Callback URL field in Publisher Account.

  1. Redirecting to the Xsolla Wallet authentication page in a pop-up window by clicking a button on your website:
    1. The user clicks a button on your website.
    2. They are redirected to the Xsolla Wallet authentication screen that opens in a popup window.
    3. The user completes the authentication process on Xsolla Wallet.
    4. They are redirected to the page whose URL is specified in the Callback URL field in Publisher Account.

How to get it

To integrate authentication via Xsolla as a social network:

  1. Create an Xsolla account OAuth 2.0 client.
  2. Integrate the login widget.
  3. Enable Xsolla as a social network.
  4. Implement the retrieval of the user authorization token.

Xsolla account OAuth 2.0 client creation

To create Xsolla account OAuth 2.0 client:
  1. Create a project in Publisher Account.
  2. Set up a Login project in Publisher Account.
  3. Contact your Customer Success Manager or email to csm@xsolla.com and provide the following information:
ParameterTypeExampleDescription
Redirect URIsArray of strings[“https://example.com/oauth/callback”, “http://localhost:3000/oauth/callback”]A list of URI addresses that can be used for redirecting the user after authentication through Xsolla account.
AudienceString“https://example.com”The domain where users can log in via Xsolla account.
ScopeArray of strings[“email”, “transactions”]List of permissions in Xsolla account.
  1. The Xsolla integration team will create an Xsolla account OAuth 2.0 client for you and provide its identifier and secret key. This data is necessary for obtaining the user authorization token.

Integration of a login widget

Integrate the login widget using SDK.

Enable Xsolla as a social network

  1. Open your project in your Publisher Account and go to the Login section.
  2. Click Configure in the pane of a Login project.
  3. Go to the Authentication section and select the Social login section.
  4. Select Xsolla from the list of social networks.
  1. Click the ⚙ icon and select Settings.
  2. Fill in the following fields:
    • Application ID — the Xsolla account OAuth 2.0 client identifier you received from Xsolla.
    • Application secret key — the Xsolla account OAuth 2.0 key you received from Xsolla.
    • Your website link — the website from which Xsolla servers receive a request to exchange an authorization code for an authorization token. Specify the same URL address that was indicated as the Audience parameter when creating the Xsolla account OAuth 2.0 client.

  1. Click Connect.

  1. Set up one of the user scenarios:
    • Redirecting to the Xsolla Wallet authentication page by clicking the Log in with Xsolla button in the login widget (by default):
      1. Go to the Authentication section and select the Callback URLs section.
      2. In the Callback URL field, enter the URL address of the page to which you want to redirect users after authentication.
      3. In the callbackUrl parameter of the login widget’s code, pass the URL address of the page to which the user should be redirected after authentication.

Widget code example:

Copy
Full screen
Small screen
import { Widget } from '@xsolla/login-sdk';
const xl = new Widget({
  projectId: '[Login ID]',
  preferredLocale: 'en_US',
  callbackUrl: '[Your Callback URL]',
});

    • Redirecting to the Xsolla Wallet authentication page in a pop-up window by clicking a button on your website:
      1. On the navigation page, go to the Authentication section and select the Callback URLs section.
      2. Make sure that the following URLs are added in the Callback URL section:
        • https://login-widget.xsolla.com/latest/babka-auth-succeed
        • https://login.xsolla.com/api/social/oauth2/callback
      3. In the login widget code pass the true value in the babkaLoginPopup parameter, and pass the URL address of the page to which the user should be redirected after authentication in the callbackUrl parameter.

Widget code example:

Copy
Full screen
Small screen
import { Widget } from '@xsolla/login-sdk';
const xl = new Widget({
  projectId: '[Login ID]',
  preferredLocale: 'en_US',
  babkaLoginPopup: true,
  callbackUrl: '[Your Callback URL]',
});

      1. Add the button opening the Xsolla Wallet authentication page to your website.

Log in with Xsolla button code example:

Copy
Full screen
Small screen
<div id="xl_auth"></div>
<button onclick="xl.open()">Babka Login Popup</button>

    • Opening the Xsolla Wallet authentication page in a modal window by clicking the Log in with Xsolla button in the login widget:
      1. Go to the Authentication section and select the Callback URLs section.
      2. In the Callback URL field, enter the URL address of the page to which you want to redirect the user after authentication.
      3. In the login widget’s code, pass the popup value in the babkaLoginFlow parameter, and pass the URL address of the page to which the user should be redirected after authentication in the callbackUrl parameter.

Widget code example:

Copy
Full screen
Small screen
import { Widget } from '@xsolla/login-sdk';
const xl = new Widget({
  projectId: '[Login ID]',
  preferredLocale: 'en_US',
  babkaLoginFlow: popup,
  callbackUrl: '[Your Callback URL]',
});

Getting a user authorization token

After authorization on the Xsolla side, the user will be redirected to the URL specified in the callback_url parameter. The user authorization token is passed in the token parameter.

To embed Xsolla account OAuth JWT token in Xsolla Login JWT token:

  1. Open your project in your Publisher Account and go to the Login section.
  2. Click Configure in the pane of a Login project.
  3. Go to the Authentication section and select the Social login section.

  1. Set the Embed social network JWT token toggler to On.
  2. Click Save changes.
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.
Rate this page
Rate this page
Is there anything we can improve?

Don’t want to answer

Thank you for your feedback!
Last updated: March 15, 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!