JSON to user profile key name map
How it works
You can map the fields of the JSON object you return in response to Xsolla Login webhooks to the following user profile properties in the Xsolla system:
- date of birth (
birthday
) - nickname (
nickname
) - first name (
first_name
) - last name (
last_name
) - gender (
gender
) - user ID on your server (
server_custom_id
)
Note
Key mapping is only available for the following Xsolla Login webhooks:
- to synchronize data with Web Shop
- to apply Mailchimp merge tags
- to implement integrations with other external systems
server_custom_id
property in the key name map, you can enable account merging by server_custom_id
. This allows our system to identify all accounts with the same server_custom_id
as belonging to the same user.Who can use it
Partners who use custom user data storage and want to use that data within Xsolla Login.
How to get it
- In your project in Publisher Account, go to the Login section.
- Select the login option and go to the User database section.
- Go to the Storage section.
- Select Custom storage.
- Choose the webhook you want to configure the key mapping for:
- user verification
- user creation
- social login
- In the Key name map block, enter the field names that should be mapped to the corresponding user profile properties.
- Set the Enable user account linking toggle to active to let our system identify all accounts with the same
server_custom_id
as belonging to the same user (optional).
Note
Account linking by
server_custom_id
is available only if you specify a key for the server_custom_id
property in the key mapping.- Click Save changes.
Note
You don’t need to include all fields in the key mapping.
Key name map usage examples
Passing user data from webhook response into JWT and user profile properties
- In response to the user verification webhook, you send the following JSON object (it can contain any set of fields):
Copy
- json
1{
2 "user": {
3 "player_id": "12345678",
4 "email": "user@example.com"
5 },
6 "user_info": {
7 "username": "gamer123",
8 "user_first_name": "John",
9 "user_last_name": "Doe",
10 "gender": "male",
11 "birthday": "1990-05-15",
12 "country": "US",
13 "language": "en"
14 },
15 "subscription_status": "active",
16 "loyalty_level": "gold"
17}
- In Publisher Account, you mapped keys to the
nickname
andserver_custom_id
properties.
- In response to the Get user details request, you will receive the following JSON:
Copy
- json
1{
2 "birthday": null,
3 "country": null,
4 "devices": [
5 {
6 "device": null,
7 "last_used_at": null,
8 "type": null
9 },
10 {
11 "device": null,
12 "last_used_at": null,
13 "type": null
14 }
15 ],
16 "email": null,
17 "external_id": null,
18 "first_name": null,
19 "gender": null,
20 "groups": [
21 {
22 "id": 1,
23 "is_default": false,
24 "name": "admin"
25 },
26 {
27 "id": 5,
28 "is_default": false,
29 "name": "user"
30 }
31 ],
32 "id": null,
33 "is_anonymous": false,
34 "last_login": null,
35 "last_name": null,
36 "nickname": "gamer123",
37 "phone": null,
38 "phone_auth": null,
39 "registered": null,
40 "tag": null,
41 "username": null
42}
Note
All values returned in the webhook response will be included in the user’s JWT token if the fields are added to the key name map. For user profile properties that are not present in the system, the response will return
null
.Using key name map and account linking during authentication in Web Shop
- The user logs in to Web Shop using their user ID. The User ID is recorded in the
server_custom_id
field of the JWT. - Web Shop sends a User validation in Web Shop webhook to your server.
- Your server responds to the webhook with HTTP
200
if the user exists, or404
if not. - Web Shop authenticates the user.
- The user logs in to Web Shop again using a different method, such as social login.
- Web Shop redirects the user to the social network’s login page.
- The user logs in to the social network.
- The social network returns the user's profile data to Web Shop.
- Web Shop sends a webhook to your Social login URL.
- Your server identifies the user based on the social network profile data and assigns them the same User ID that was used during the User ID authentication.
- Your server responds with a
2xx
code and includes a JSON body containing the User ID. - Web Shop saves the user attributes and adds the data from the webhook response to the
partner_data
field in the JWT. - If the key name map includes a key for
server_custom_id
and account linking is enabled, Web Shop maps the received user data to the profile properties based on the key name map and links the accounts. - Web Shop authenticates the user into the same account used during the User ID login.
Was this article helpful?
Thank you for your feedback!
We’ll review your message and use it to help us improve your experience.Continue reading
Useful links
Custom user data storageFound a typo or other text error? Select the text and press Ctrl+Enter.