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:
- The unauthorized user starts the game.
- The game relates the user with session information.
- After a certain time, the game asks the user to register in order to continue.
- The game sends a registration request with the passed session information to the Xsolla Login server.
- The Xsolla Login server registers the user. As a result of registration, the information about the session is passed in the user JWT.
- The game transfers the progress to the registered user.
- The user continues to play as authorized.
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:
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
Example of the request (identifier of the user’s session):
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):
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):
- html
<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):
- html
<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
- json
{
"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
- json
{
"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"
}
Found a typo or other text error? Select the text and press Ctrl+Enter.