How to integrate user authentication via Xsolla account
How it works
You can add user authentication with Xsolla account on Xsolla Wallet.
User scenarios
You can implement one of the following user scenarios:
- Opening the Xsolla Wallet authentication page in a modal window by clicking the Log in with Xsolla button in the login widget:
- The user clicks the Log in with Xsolla button in the login widget.
- They are redirected to the Xsolla Wallet authentication screen that opens in a modal window.
- The user completes the authentication process on Xsolla Wallet.
- They are redirected to the page whose URL is specified in the Callback URL field in Publisher Account.
- Redirecting to the Xsolla Wallet authentication page by clicking the Log in with Xsolla button in the login widget:
- The user clicks the Log in with Xsolla button in the login widget.
- They are redirected to the Xsolla Wallet authentication screen that opens in the same window.
- The user completes the authentication process on Xsolla Wallet.
- They are redirected to the page whose URL is specified in the Callback URL field in Publisher Account.
- Redirecting to the Xsolla Wallet authentication page in a pop-up window by clicking a button on your website:
- The user clicks a button on your website.
- They are redirected to the Xsolla Wallet authentication screen that opens in a popup window.
- The user completes the authentication process on Xsolla Wallet.
- 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:
- Create an Xsolla account OAuth 2.0 client.
- Integrate the login widget.
- Enable Xsolla as a social network.
- Implement the retrieval of the user authorization token.
Xsolla account OAuth 2.0 client creation
To create Xsolla account OAuth 2.0 client:- Create a project in Publisher Account.
- Set up a Login project in Publisher Account.
- Contact your Customer Success Manager or email to csm@xsolla.com and provide the following information:
Parameter | Type | Example | Description |
---|---|---|---|
Redirect URIs | Array 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. |
Audience | String | “https://example.com” | The domain where users can log in via Xsolla account. |
Scope | Array of strings | [“email”, “transactions”] | List of permissions in Xsolla account. |
- 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
- Open your project in your Publisher Account and go to the Login section.
- Click Configure in the pane of a Login project.
- Go to the Authentication section and select the Social login section.
- Select Xsolla from the list of social networks.
- Click the ⚙ icon and select Settings.
- 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.
- Click Connect.
- 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):
- Go to the Authentication section and select the Callback URLs section.
- In the Callback URL field, enter the URL address of the page to which you want to redirect users after authentication.
- 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.
- Redirecting to the Xsolla Wallet authentication page by clicking the Log in with Xsolla button in the login widget (by default):
Widget code example:
- javascript
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:
- On the navigation page, go to the Authentication section and select the Callback URLs section.
- 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
- In the login widget code pass the
true
value in thebabkaLoginPopup
parameter, and pass the URL address of the page to which the user should be redirected after authentication in thecallbackUrl
parameter.
- Redirecting to the Xsolla Wallet authentication page in a pop-up window by clicking a button on your website:
Widget code example:
- javascript
import { Widget } from '@xsolla/login-sdk';
const xl = new Widget({
projectId: '[Login ID]',
preferredLocale: 'en_US',
babkaLoginPopup: true,
callbackUrl: '[Your Callback URL]',
});
- Add the button opening the Xsolla Wallet authentication page to your website.
Log in with Xsolla button code example:
- html
<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:
- Go to the Authentication section and select the Callback URLs section.
- In the Callback URL field, enter the URL address of the page to which you want to redirect the user after authentication.
- In the login widget’s code, pass the
popup
value in thebabkaLoginFlow
parameter, and pass the URL address of the page to which the user should be redirected after authentication in thecallbackUrl
parameter.
- Opening the Xsolla Wallet authentication page in a modal window by clicking the Log in with Xsolla button in the login widget:
Widget code example:
- javascript
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:
- Open your project in your Publisher Account and go to the Login section.
- Click Configure in the pane of a Login project.
- Go to the Authentication section and select the Social login section.
- Set the Embed social network JWT token toggler to On.
- Click Save changes.
Found a typo or other text error? Select the text and press Ctrl+Enter.