https://login.xsolla.com/api
Cette section décrit les appels API pour interagir avec Login. Configurez votre projet de connexion dans le Compte éditeur avant d'envoyer des requêtes.
Vous avez accès aux types de projets de connexion suivants dans le Compte éditeur :
Pour plus d'informations, voir la fonctionnalité Compte multiplateforme.
Login API prend en charge les types de jetons suivants :
Le schéma d'authentification permet de déterminer si un appel API est effectué côté client ou côté serveur :
Authorization
header: Bearer <user_JWT>
header,
where <user_JWT>
— is the user token.X-SERVER-AUTHORIZATION: <server_JWT>
, where
<server_JWT>
— is the server token.Pour obtenir le jeton, envoyez l'une des requêtes suivantes :
Après l'authentification JWT, l'utilisateur est redirigé vers l'URL de rappel
avec le jeton inclus dans le paramètre de la requête : <Callback URL>?token=<User token (JWT)>
.
Après l'authentification basée sur le protocole OAuth 2.0, envoyez la requête
Générer un JWT au serveur Xsolla Login pour échanger le paramètre code
reçu contre un
jeton utilisateur (access_token
).
Pour obtenir un jeton de serveur :
Côté client de votre application, implémentez une méthode pour obtenir le JWT du serveur en utilisant l'appel Générer une API JWT. La requête doit contenir les paramètres suivants :
grant_type
est le type de JWT obtenu, passez la valeur client_credentials
.client_secret
est la clé secrète obtenue lors de la configuration du client
OAuth 2.0 du serveur.client_id
est l'ID client obtenu lors de la configuration du client OAuth 2.0
du serveur.Pour éviter de surcharger le système Xsolla et prévenir les pics soudains de
trafic entrant, Xsolla limite le nombre de requêtes reçues par l'API Xsolla au
cours d'une période donnée. Si la limite est dépassée, l'API Xsolla renvoie une
réponse HTTP avec le code d'état 429
.
Rate limits vary by method, IP-address, authentication scheme, and other factors.
Rate limits for server-side methods are applied to methods with server-side
authentication — methods that are called with the X-SERVER-AUTHORIZATION:
<server_JWT>
header, where <server_JWT>
is the server
token.
Rate limits for client-side methods are applied to methods without
authentication or with client-side authentication — methods that are called
with the Authorization: Bearer <user_JWT>
header, where
<user_JWT>
is the user token.
Example of a method with server-side authentication: Example of a method with client-side authentication:
Les limites de fréquence pour les méthodes côté client restent inchangées et sont essentielles pour prévenir les attaques par force brute. En revanche, la fréquence maximale des requêtes pour les méthodes côté serveur est plus élevée que celle des méthodes côté client. Pour des recommandations sur la gestion des limites de fréquence, consultez la documentation .
Chaque jeton est au format JWT et contient une information précise dans une charge utile.
Le JWT utilisateur est un jeton obtenu à la suite d'une authentification ou d'un enregistrement. Il contient des informations sur l'utilisateur et des données sur l'appel d'authentification
L'obtention d'un jeton utilisateur via le protocole OAuth 2.0 nécessite un
client OAuth 2.0. Le jeton utilisateur est passé dans l'en-tête Authorization: Bearer <JWT>
.
Un jeton contient les revendications principales après l'authentification ou la confirmation de l'adresse e-mail. La présence de ces revendications ne dépend pas de la base de données utilisateur ni de l'appel d'authentification.
Revendication | Type | Obligatoire | Description |
exp |
Horodatage Unix | Oui | Date et heure d'expiration du jeton. Par défaut, le délai d'expiration est de 24 heures, mais il est modifiable pour chaque projet de connexion. |
iss |
string | Oui | Service qui a signé le jeton : https://login.xsolla.com . |
iat |
Horodatage Unix | Oui | Date et heure de la remise du jeton. |
sub |
string (UUID) | Oui | ID de l'utilisateur enregistré côté serveur Xsolla Login. |
groups |
array | Oui |
La liste des groupes dont fait partie l'utilisateur. Chaque groupe est écrit au format suivant :
Il ne peut y avoir qu'un seul groupe par défaut. Ce groupe comprend initialement tous les utilisateurs avant qu'ils ne soient répartis dans différents groupes. |
xsolla_login_project_id |
string (UUID) | Oui | ID du projet de connexion. |
type |
string |
Option d'authentification :
Il ne peut y avoir qu'un seul groupe par défaut. Ce groupe comprend initialement tous les utilisateurs avant qu'ils ne soient répartis dans différents groupes. |
|
avatar |
string | URL de l'avatar de l'utilisateur. | |
username |
string | Nom d'utilisateur. | |
publisher_id |
integer | ID du commerçant, propriétaire du projet de connexion. | |
email |
string | Adresse e-mail de l'utilisateur. | |
payload |
string | Informations supplémentaires passées dans le paramètre de charge utile lors de l'authentification. | |
promo_email_agreement |
boolean |
Valeurs possibles :
true .
Pour ajouter cette fonctionnalité au formulaire d'enregistrement du widget Login : |
|
connection_information |
string | Indique si l'utilisateur a confirmé ou non sa date de naissance. La confirmation se fait via le service okname. |
Revendications contenues dans le jeton après l'authentification si vous utilisez le stockage PlayFab.
Revendication | Type | Obligatoire | Description |
external_account_id |
string | Oui | ID PlayFab de l'utilisateur. |
session_ticket |
string | Oui |
Paramètre SessionTicket reçu lors d'une requête d'authentification ou lors des requêtes à PlayFab API. Le jeton contient cette revendication si vous authentifiez les utilisateurs via le protocole OAuth 2.0 et que vous passez la valeur |
entity_token |
string | Oui | Paramètre EntityToken.EntityToken. |
entity_type |
string | Oui | Paramètre EntityToken.Entity.Type. Unique valeur possible title_player_account . |
entity_id |
string | Oui | Paramètre EntityToken.Entity.Id. |
Revendications contenues dans le jeton après l'authentification si vous utilisez un stockage personnalisé.
Revendication | Type | Obligatoire | Description |
provider |
string | Oui | Nom du réseau social utilisé pour l'authentification. Si l'utilisateur s'authentifie par son nom d'utilisateur et son mot de passe, la revendication a la valeur xsolla . |
external_account_id |
string | ID de l'utilisateur sur votre serveur. | |
partner_data |
Data of any type returned by your server in the response body during authentication. To enable the transmission of this claim, contact your Customer Success Manager or email to csm@xsolla.com | ||
social_access_token |
Access token of the social network through which the user was authenticated. To enable the transmission of this claim, contact your Customer Success Manager or email to csm@xsolla.com. |
Revendications contenues dans le jeton après l'authentification via un réseau social. La présence de ces revendications ne dépend pas de la base de données des utilisateurs.
Revendication | Type | Obligatoire | Description |
provider |
string | Oui | Nom du réseau social utilisé pour l'authentification. |
id |
string | Oui | ID utilisateur dans un réseau social. |
is_cross_auth |
boolean | Indique que la requête d'authentification silencieuse est en cours. | |
social_access_token |
string | Paramètre access_token du compte de réseau social utilisé pour l'authentification. Contactez votre gestionnaire de compte pour configurer cette fonctionnalité. |
|
picture |
string (URL) | Lien vers la photo de profil de l'utilisateur dans un réseau social. | |
birthday |
date (RFC3339) | Date de naissance de l'utilisateur dans un réseau social. | |
gender |
string | Genre de l'utilisateur dans un réseau social. | |
name |
string | Pseudo de l'utilisateur dans un réseau social. |
Revendication contenue dans le jeton après l'authentification par numéro de téléphone.
Revendication | Type | Obligatoire | Description |
phone_number |
string | Oui | Numéro de téléphone de l'utilisateur utilisé pour l'authentification. Le format du numéro se compose de l'indicatif du pays, de l'indicatif régional et du numéro de ligne, sans aucun séparateur. |
Le jeton du serveur est passé dans l'en-tête X-SERVER-AUTHORIZATION
.
La charge utile du jeton contient des informations sur les ressources dont le client OAuth 2.0 est propriétaire. Le jeton a accès aux appels avec authentification côté serveur pour ces ressources.
Revendication | Type | Obligatoire | Description |
xsolla_login_project_id |
string (UUID) | Oui | ID du projet de connexion dont le client OAuth 2.0 est propriétaire. |
resources |
array | Oui |
Liste des ressources dont le client OAuth 2.0 est propriétaire. Types de ressources possibles :
Chaque groupe est écrit dans le format suivant :
|
jti |
string | Oui | ID unique du jeton. |
To validate the JWT, use the following Login API calls:
Remarque
Ne révélez votre clé secrète à personne. Si elle a été compromise, mettez-la à jour.
En cas d'erreur, le serveur Xsolla Login renvoie un objet JSON contenant les champs suivants :
Champ | Type | Description |
code | string | Code d'erreur du serveur Xsolla Login. |
description | string | Description de l'erreur. Le texte est toujours en anglais. N'utilisez pas ce texte en cas d'erreur, car la valeur peut changer à l'avenir. |
{
"error": {
"code": "000-000",
"description": "description"
}
}
Error Code | Description | Recommendation |
---|---|---|
002-016 | The user should try to log in again. | |
002-027 | Make sure all request parameters are correct. | |
002-028 | Make sure all required parameters are provided. | |
002-040 | The user should contact the game support team. | |
002-043 | The user should try another phone number that can receive SMS. | |
002-050 | The error occurs when trying to enable two-factor authentication if it's already enabled, or disable it if it's already disabled. | |
002-056 | The user should verify the phone number or enter a different one. | |
002-057 | The user should try again later. If you believe this error should not occur, please contact the integrator team in any messenger. | |
002-058 | The user should use the link in the email to unblock their account or reset the password. | |
002-060 | Inform the user of the age restrictions. | |
003-001 | The user should verify the entered information and try again. | |
003-002 | The user should sign up in the game to continue. | |
003-003 | The user should try a different username. | |
003-004 | The user should use a different email address. | |
003-005 | The user should try a different email address. | |
003-007 | The user should confirm their email address to activate the account. If they haven't received a confirmation email, they should check the spam folder. | |
003-008 | Changing the email address is not allowed. | |
003-009 | The search failed for technical reasons, please try again later. | |
003-010 | Changing the birth date is not allowed. | |
003-011 | The user should confirm the email address or use another one that has not been previously used during registration. | |
003-012 | The user should confirm the phone number or use another one that has not been previously used during registration. | |
003-019 | Check the existence of the authentication variant with the passed ID. | |
003-020 | Check the authorization option settings in your Publisher Account. | |
003-021 | The user should contact game support. | |
003-022 | Verify the authorization option settings in your Publisher Account. | |
003-023 | Registration is not allowed for this authorization option. The user should contact game support. | |
003-030 | The password reset link has expired or is incorrect. The user should attempt to reset the password again. | |
003-049 | The user should try again later. | |
007-001 | The user should use an alternative login method. | |
008-001 | Add the correct login URL in the authorization option settings in your Publisher Account (section User database > Storage > Custom storage). | |
008-002 | Add the correct user verification URL in the authorization option settings in your Publisher Account (section User database > Storage > Custom storage). | |
008-003 | Add the correct URL in the authorization option settings in your Publisher Account (section User database > Storage > Custom storage). | |
008-004 | Add the correct password reset URL in the authorization option settings in your Publisher Account (section User database > Storage > Custom storage). | |
008-005 | Ensure the correct Title ID is specified in the authorization option settings in your Publisher Account (section User database > Storage). | |
008-006 | Ensure the PlayFab API key is valid. | |
008-008 | Ensure the server returns the accountID parameter in the response body. |
|
008-009 | Verify the URLs specified in the Custom storage settings in the authorization option in your Publisher Account (section User database > Storage > Custom storage). | |
008-011 | Ensure that the callback URL for password reset is specified in the authorization option settings in your Publisher Account (section Password settings). | |
008-013 | Ensure that a link to the user agreement is specified in the authorization option settings in your Publisher Account (section Legal Terms > Policies and Agreements). | |
008-014 | Contact the integration team through any messenger. | |
008-015 | Contact the integration team through any messenger. | |
008-016 | Add the API key to the settings in your Publisher Account (section Legal Terms > Policies and Agreements). | |
010-004 | The user should try again later. | |
010-005 | The user should try again later. | |
010-006 | The user should add another authentication method before unlinking the social network. | |
010-007 | The user should complete the CAPTCHA again. | |
010-010 | The user should verify the code and try again. | |
010-014 | The user should log in again from the login page. | |
010-015 | The user should try again later. | |
010-016 | The user should use a different social account. If they believe this is an error, they should contact the integration team through any messenger. | |
010-017 | Verify the correctness of the request parameters being sent. | |
010-019 | Ensure that a client with the provided client_id exists. |
|
010-020 | Ensure that the provided scope parameter is correct. Refer to the instructions for detailed setup information. |
|
010-021 | Ensure that the value of the response_type parameter is set to "code" . |
|
010-022 | Ensure that the state parameter is present and consists of at least 8 characters. | |
010-023 | Ensure that the authorization code is valid and not expired, and that the redirect_uri parameter contains an authorized URL. Refer to the instructions for detailed setup information. |
|
010-026 | Ensure that you have sufficient permissions to access the resource. | |
010-030 | Ensure that cross-authentication is enabled for the authorization option. Refer to the instructions for detailed setup information. | |
010-031 | The error occurs when attempting to connect a social network that is already enabled. | |
010-032 | Ensure that the social network is enabled and configured in the authorization option settings in your Publisher Account (section Authorization via Social Networks). | |
010-033 | The user should try again later. | |
010-035 | The user should try again later. | |
010-045 | The user should use a different social account for registration. | |
030-024 | The user should contact the game support team. | |
040-001 | The user should enter an email address containing no more than 254 characters. | |
040-002 | The user should enter a valid email address. | |
040-003 | The user should enter a different email address. | |
040-004 | The user should contact Xsolla support. | |
040-005 | The user should enter an email with only one @ character. |
|
040-006, 040-007, 040-008 | The user should contact Xsolla support. | |
040-009 | The user should enter an email with an existing domain. | |
040-010 | The user should contact Xsolla support. | |
010-018 | The user should enter a different email address. | |
300-003 | The user should try again later. | |
300-005 | The user should try again later. | |
300-006 | The user should verify and re-enter the confirmation code. | |
300-008 | The user should use the new code sent to their email or phone. | |
003-007 | The user should confirm their email address to activate the account. If they haven't received a confirmation email, they should check the spam folder. | |
003-025 | The user should try a different authentication method. | |
003-040 | The user should log in again. | |
003-033 | Ensure that shadow authentication is used for the authorization option. | |
2002-0001 | Make sure that the attribute being created has not been previously added to the user. |