https://login.xsolla.com/api
Esta seção descreve as chamadas de API para trabalhar com Login. Configure seu projeto Login na Conta de Distribuidor antes de enviar solicitações.
Você tem acesso aos seguintes tipos de projeto Login na Conta de Distribuidor:
Para obter mais informações sobre ele, consulte o recurso Conta multiplataforma.
A Login API oferece suporte aos seguintes tipos de token:
Você pode determinar se uma chamada de API ocorre no lado do cliente ou do servidor pelo esquema de autenticação:
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.Para obter o token, envie uma das seguintes solicitações:
Após a autenticação JWT, o usuário é redirecionado para o URL de retorno de
chamada com um token em um parâmetro de consulta: <Callback URL>?token=<User token (JWT)>
.
Após a autenticação baseada no protocolo OAuth 2.0, envie a solicitação
Generate JWT
ao servidor do Xsolla Login para trocar o parâmetro code
recebido por um
token de usuário (access_token
).
Para obter um token de servidor:
No back-end do seu aplicativo, implemente um método para obter o JWT do servidor usando a chamada Generate JWT API. A solicitação deve conter os seguintes parâmetros:
grant_type
é o tipo de obtenção de JWT; passa o valor client_credentials
.client_secret
é a chave secreta que é recebida quando você configura o
cliente OAuth 2.0 do servidor.client_id
é o ID do cliente recebido quando você configura o cliente OAuth
2.0 do servidor.Para evitar sobrecarregar o sistema Xsolla e proteger contra picos repentinos
no tráfego de entrada, a Xsolla limita o número de solicitações recebidas pela
API Xsolla dentro de um período de tempo especificado. Se o limite for
excedido, a API Xsolla retornará uma resposta HTTP com o código de status
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:
Os limites de taxa para métodos do lado do cliente não mudam e são necessários para evitar ataques de força bruta. A taxa máxima de solicitação para métodos do lado do servidor é maior do que para métodos do lado do cliente. Você pode consultar as recomendações sobre como gerenciar limites de taxa na documentação.
Cada token tem um formato JWT e contém uma informação definida em uma carga.
O JWT do usuário é um token recebido como resultado da autenticação ou cadastro. Uma carga de token contém informações sobre o usuário e a chamada de autenticação.
Para obter um token de usuário por meio do protocolo OAuth 2.0, você precisa de
um cliente OAuth 2.0. O token de usuário é passado no cabeçalho Authorization: Bearer <JWT>
.
Um token conterá as principais declarações após a autenticação ou confirmação do endereço de e-mail. A presença dessas declarações não depende do banco de dados do usuário e da chamada de autenticação.
Reivindicar | Tipo | Obrigatório | Descrição |
exp |
Carimbo de data/hora Unix | Sim | Data e hora da expiração do token. O tempo de expiração padrão é de 24 horas. Você pode alterar o tempo de expiração para cada projeto Login. |
iss |
cadeia de caracteres | Sim | Serviço que assinou o token: https://login.xsolla.com . |
iat |
Carimbo de data/hora Unix | Sim | Data e hora de entrega do token. |
sub |
cadeia de caracteres (UUID) | Sim | ID do usuário escrito no lado do servidor Xsolla Login. |
groups |
matriz | Sim |
A lista de grupos em que o usuário está. Cada grupo é escrito no seguinte formato:
Só pode haver um grupo padrão. Esse grupo inicialmente inclui todos os usuários antes que eles sejam distribuídos em grupos diferentes. |
xsolla_login_project_id |
cadeia de caracteres (UUID) | Sim | ID do projeto Login. |
type |
cadeia de caracteres |
Opção de autenticação:
Só pode haver um grupo padrão. Esse grupo inicialmente inclui todos os usuários antes que eles sejam distribuídos em grupos diferentes. |
|
avatar |
cadeia de caracteres | URL do avatar do usuário. | |
username |
cadeia de caracteres | Nome de usuário. | |
publisher_id |
número inteiro | ID de um comerciante que possui um projeto de login. | |
email |
cadeia de caracteres | Endereço de e-mail do usuário. | |
payload |
cadeia de caracteres | Informações adicionais que são passadas no parâmetro de carga durante a autenticação. | |
promo_email_agreement |
valor booleano |
Pode ter um dos seguintes valores:
true por padrão.
Para adicionar o recurso ao formulário de registro do Login widget:
|
|
connection_information |
cadeia de caracteres | Mostra se o usuário confirmou a data de nascimento ou não. A confirmação é feita através do serviço okname. |
Declarações contidas no token após a autenticação se você usar o armazenamento PlayFab.
Reivindicar | Tipo | Obrigatório | Descrição |
external_account_id |
cadeia de caracteres | Sim | ID do usuário PlayFab. |
session_ticket |
cadeia de caracteres | Sim |
Um parâmetro SessionTicket recebido durante uma solicitação de autenticação ou solicitações para a PlayFab API. Um token conterá a declaração se você autenticar usuários por meio do protocolo OAuth 2.0 e passar o valor |
entity_token |
cadeia de caracteres | Sim | Um parâmetro EntityToken.EntityToken. |
entity_type |
cadeia de caracteres | Sim | Um parâmetro EntityToken.Entity.Type. Só aceita o valor title_player_account . |
entity_id |
cadeia de caracteres | Sim | Um parâmetro EntityToken.Entity.Id. |
Declarações contidas no token após a autenticação se você usar armazenamento personalizado.
Reivindicar | Tipo | Obrigatório | Descrição |
provider |
cadeia de caracteres | Sim | Nome de uma rede social usada para autenticação. Se o usuário autenticar via nome de usuário e senha, a declaração terá o valor xsolla . |
external_account_id |
cadeia de caracteres | ID do usuário no lado do servidor. | |
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. |
Reivindicação que está contida no token após a autenticação por meio de um número de telefone.
Reivindicar | Tipo | Obrigatório | Descrição |
phone_number |
cadeia de caracteres | Sim | Número de telefone do usuário usado para autenticação. O formato de número de telefone com base no código do país, código de área e número de linha sem divisórias. |
O token do servidor é passado no cabeçalho X-SERVER-AUTHORIZATION
.
A carga do token contém informações sobre recursos pertencentes ao cliente OAuth 2.0. O token tem acesso a chamadas com autenticação baseada em servidor para esses recursos.
Reivindicar | Tipo | Obrigatório | Descrição |
xsolla_login_project_id |
cadeia de caracteres (UUID) | Sim | ID de um projeto Login que possui o cliente OAuth 2.0. |
resources |
matriz | Sim |
Lista de recursos pertencentes a um cliente OAuth 2.0. Tipos possíveis de recursos:
Cada grupo é escrito no seguinte formato:
|
jti |
cadeia de caracteres | Sim | ID de token exclusivo. |
To validate the JWT, use the following Login API calls:
Aviso
Não revele sua chave secreta a ninguém. Se ela foi comprometida, atualize-a.
Em caso de respostas de erro, o servidor do Xsolla Login retorna um objeto JSON com os seguintes campos:
Campo | Tipo | Descrição |
código | cadeia de caracteres | Código de erro do servidor Xsolla Login. |
descrição | cadeia de caracteres | Descrição do erro. O texto está sempre em inglês. Não use este texto em caso de erro, pois o valor pode mudar no futuro. |
{
"error": {
"code": "000-000",
"description": "description"
}
}
Error Code | Descrição | 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. |