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 Login API

Pass the payload parameter to the Register 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):

Copy
Full screen
Small screen

http

  • http
  • curl
POST https://login.xsolla.com/api/user?login_url=https://example.com&projectId=00000000-0000-0000-0000-000000000000&payload=my_session_123 HTTP/1.1
Content-Type: application/json

{
  "username": "John Smith",
  "password": "123456",
  "email": "john-email@email.com"
}
curl --request POST \
  --url 'https://login.xsolla.com/api/user?login_url=https%3A%2F%2Fexample.com&projectId=00000000-0000-0000-0000-000000000000&payload=my_session_123' \
  --header 'content-type: application/json' \
  --data '{"username":"John Smith","password":"123456","email":"john-email@email.com"}'

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

Copy
Full screen
Small screen

http

  • http
  • curl
POST https://login.xsolla.com/api/user?login_url=https://example.com&projectId=00000000-0000-0000-0000-000000000000&payload={"coins":120,"lvl":2} HTTP/1.1
Content-Type: application/json

{
  "username": "John Smith",
  "password": "123456",
  "email": "john-email@email.com"
}
curl --request POST \
  --url 'https://login.xsolla.com/api/user?login_url=https%3A%2F%2Fexample.com&projectId=00000000-0000-0000-0000-000000000000&payload=%7B%22coins%22%3A120%2C%22lvl%22%3A2%7D' \
  --header 'content-type: application/json' \
  --data '{"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):

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

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

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

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):

Copy
Full screen
Small screen
{
  "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):

Copy
Full screen
Small screen
{
  "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"
}
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: July 31, 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!