Delayed registration in browser games

How It Works

The user can start a game in a browser without registration. After a certain time, the user will be asked to register and their progress in the game will be saved. Registration waiting time must be implemented at the game side.

The interaction flow between the user and the game is as follows:

  1. The unauthorized user starts the game.
  2. The game relates the user with session information.
  3. After a certain time, the game asks the user to register in order to continue.
  4. The game sends a registration request with the passed session information to the Xsolla Login server.
  5. The Xsolla Login server registers the user. As a result of registration, the information about the session is passed in the user JWT.
  6. The game transfers the progress to the registered user.
  7. The user continues to play as authorized.

Note: The session identifier or JSON string with information about the user's progress is passed as information about the user's session.

Who Can Use It

Partners who have already integrated Login and have a browser game.

How to Get It

To save the user progress after registration in the game:

  1. Pass information about the user’s session when registering.
  2. Transfer the game progress to the user.

Passing Information About User’s Session

Passing information about the user’s session depends on the Login integration:

Integrating via API Methods

Pass the payload parameter to the Register a New User request. Specify information about the user's session as the value for this parameter.

Example of the request (identifier of the user’s session):

POST https://login.xsolla.com/api/user?login_url=https://example.com&projectId=00000000-0000-0000-0000-000000000000&payload=my_session_123

Headers:
Content-Type: application/json

Body:
{
  "username": "John Smith",
  "password": "123456",
  "email": "john-email@email.com"
}

Example of the request (JSON string with information about the user’s progress):

POST https://login.xsolla.com/api/user?login_url=https://example.com&projectId=00000000-0000-0000-0000-000000000000&payload={"coins":120,"lvl":2}

Headers:
Content-Type: application/json

Body:
{
  "username": "John Smith",
  "password": "123456",
  "email": "john-email@email.com"
}

Integrating via Login Widget

Add the payload parameter to the widget initialization code. Specify information about the user's session as the value for this parameter.

Example of the widget initialization code (identifier of the user’s session):

<script>
const xl = new XsollaLogin.Widget({
  projectId: '00000000-0000-0000-0000-000000000000',
  preferredLocale: 'en_US',
  callbackUrl: 'https://example.com',
  payload: 'my_session_123'
});

Example of the widget initialization code (JSON string with information about the user’s progress):

<script>
const xl = new XsollaLogin.Widget({
  projectId: '00000000-0000-0000-0000-000000000000',
  preferredLocale: 'en_US',
  callbackUrl: 'https://example.com',
  payload: '{"coins":120,"lvl":2}'
});

Transferring Game Progress to User

After registration, information about the user’s session is passed in the payload claim of the user JWT. Use this information to transfer the progress received during the session. You can find the identifier of the registered user in the sub claim of the user JWT.

Example of the JWT payload (identifier of the user’s session):

{
  "email": "john-email@email.com",
  "exp": 1597904900,
  "iat": 1597818500,
  "is_master": true,
  "iss": "https://login.xsolla.com",
  "payload": "my_session_123",
  "promo_email_agreement": true,
  "publisher_id": 0,
  "sub": "00000000-0000-0000-0000-000000000000",
  "type": "xsolla_login",
  "username": "John Smith",
  "xsolla_login_access_key": "422nH1zNMIVKCesi7r4YdQXQY-jgbf2CIcvGdCREDIA",
  "xsolla_login_project_id": "00000000-0000-0000-0000-000000000000"
}

Example of the JWT payload (JSON string with information about the user’s progress):

{
  "email": "john-email@email.com",
  "exp": 1597904900,
  "iat": 1597818500,
  "is_master": true,
  "iss": "https://login.xsolla.com",
  "payload": "{\"coins\":120,\"lvl\":2}",
  "promo_email_agreement": true,
  "publisher_id": 0,
  "sub": "00000000-0000-0000-0000-000000000000",
  "type": "xsolla_login",
  "username": "John Smith",
  "xsolla_login_access_key": "422nH1zNMIVKCesi7r4YdQXQY-jgbf2CIcvGdCREDIA",
  "xsolla_login_project_id": "00000000-0000-0000-0000-000000000000"
}