https://login.xsolla.com/api
Login API支持以下令牌类型:
您可以按照身份认证机制来判断一个API调用属于客户端侧还是服务器侧:
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.要获取令牌,请发送以下请求之一:
JWT认证后,用户将重定向到在查询参数中包含令牌的回调URL:<Callback URL>?token=<User token (JWT)>
。
After OAuth 2.0 protocol-based authentication, send the Generate
JWT POST
request to the Xsolla Login server to exchange the received code
parameter
for a user token (access_token
).
When the access token expires, the client sends Generate
JWT POST
request endpoint on the Xsolla Login server. The request body must include the
following parameters:
grant_type
— JWT grant type, pass the refresh_token
value.client_id
— OAuth 2.0 client ID.refresh_token
— refresh token received in response to the user authorization
request.要获取服务器令牌:
在应用程序的后端,实现使用生成JWT API调用获取服务器JWT的方法。请求必须包含以下参数:
grant_type
is the type of getting JWT, pass the client_credentials
value.client_secret
is the secret key that is received when you set up the server
OAuth 2.0 client.client_id
is the client ID received when you set up the server OAuth 2.0
client.When the server token expires, generate a new token using the Generate JWT API call. The request body must include the following parameters:
grant_type
— JWT grant type, pass the client_credentials
value.client_id
— OAuth 2.0 client ID.client_secret
— OAuth 2.0 client secret key.To prevent Xsolla system overloads and protect against sudden spikes in
incoming traffic, Xsolla limits the number of requests received by the Xsolla
API within a specified period of time. If the limit is exceeded, the Xsolla API
returns an HTTP response with the 429
status code.
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:
Rate limits for client-side methods do not change and are necessary to prevent brute-force attacks. The maximum request rate for server-side methods is higher than for client-side methods. You can refer to the recommendations on how to manage rate limits in the documentation.
每个密钥都一个JWT格式,并在负载中包含固定的信息。
身份认证或邮箱地址确认后,令牌会包含主要声明。这些声明的存在不依赖于用户数据库和认证调用。
声明 | 类型 | 必需 | 描述 |
exp |
Unix时间戳 | 是 | 令牌过期的日期和时间。默认过期时间是24小时。您可以更改各登录管理器项目的过期时间。 |
iss |
string | 是 | 给令牌签名的服务:https://login.xsolla.com 。 |
iat |
Unix时间戳 | 是 | 授予令牌的日期和时间。 |
sub |
字符串(UUID) | 是 | 写入在艾克索拉登录管理器服务器侧的用户ID。 |
groups |
array | 是 |
用户所在组的列表。每个组的写入格式如下:
只能有一个默认组。该组最初包含将用户分到不同组之前的所有用户。 |
xsolla_login_project_id |
字符串(UUID) | 是 | 登录管理器项目ID。 |
type |
string |
身份认证选项:
只能有一个默认组。该组最初包含将用户分到不同组之前的所有用户。 |
|
avatar |
string | 用户头像URL。 | |
username |
string | 用户名。 | |
publisher_id |
integer | 拥有登录管理器项目的商户ID。 | |
email |
string | 用户邮箱地址。 | |
payload |
string | 身份认证过程中在payload参数中传递的附加信息。 | |
promo_email_agreement |
boolean |
可以是以下值之一:
true 值。
要向登录管理器小组件的注册表单添加该功能:
|
|
connection_information |
string | 显示用户是否确认了其出生日期。确认由okname服务进行。 |
如果使用PlayFab存储,身份认证后包含在令牌中的声明如下。
声明 | 类型 | 必需 | 描述 |
external_account_id |
string | 是 | 用户PlayFab ID。 |
session_ticket |
string | 是 |
认证请求或向PlayFab API发送请求期间收到的SessionTicket参数。 如果通过OAuth 2.0协议来认证用户并向 |
entity_token |
string | 是 | 一个EntityToken.EntityToken参数。 |
entity_type |
string | 是 | 一个EntityToken.Entity.Type参数。只能有title_player_account 值。 |
entity_id |
string | 是 | 一个EntityToken.Entity.Id参数。 |
如果使用自定义存储,身份认证后包含在令牌中的声明如下。
声明 | 类型 | 必需 | 描述 |
provider |
string | 是 | 认证使用的社交网络的名称。如果用户通过用户名和密码进行认证,则声明的值为xsolla 。 |
external_account_id |
string | 您服务器侧的用户ID。 | |
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. |
通过社交网络进行认证后包含在令牌中的声明如下。这些声明的存在不依赖于用户数据库。
声明 | 类型 | 必需 | 描述 |
provider |
string | 是 | 认证使用的社交网络的名称。 |
id |
string | 是 | 社交网络中的用户ID。 |
is_cross_auth |
boolean | 显示静默认证请求正在进行中。 | |
social_access_token |
string | 用于认证的社交网络帐户access_token 参数。请联系您的帐户经理设置该功能。 |
|
picture |
字符串(URL) | 社交网络中用户个人资料图片的链接。 | |
birthday |
日期(RFC3339) | 社交网络中的用户出生日期。 | |
gender |
string | 社交网络中的用户性别。 | |
name |
string | 社交网络中的用户昵称。 |
服务器令牌在X-SERVER-AUTHORIZATION
头中传入。
令牌负载包含OAuth 2.0客户端拥有的资源的信息。令牌可以访问对这些资源有基于服务器认证的调用。
声明 | 类型 | 必需 | 描述 |
xsolla_login_project_id |
字符串(UUID) | 是 | OAuth 2.0客户端所属登录管理器项目的ID。 |
resources |
array | 是 |
OAuth 2.0客户端拥有的资源的列表。可能的资源类型:
各组的写入格式如下:
|
jti |
string | 是 | 唯一令牌ID。 |
To validate the JWT, use the following Login API calls:
注意
请勿将密钥告诉任何人。如果发生密钥泄露,请立即更新。
Refer to the documentation for information about Xsolla Login API errors.