Xsolla-logo

生成JWT

post/oauth2/token

使用此调用:

  • 获取用户JWT
  • 在JWT过期时刷新。仅当在注册或认证调用中传入了scope=offline时才有效。
  • 获取服务器JWT。不需要用户参与。

此调用的使用取决于grant_type参数的值。

Request
Request Body schema: application/x-www-form-urlencoded
grant_type
required
string

获取JWT的类型。可以是:

  • authorization_code,将认证调用中收到的代码交换给JWT。必须指定code参数的值。
  • refresh_token,在上一个值过期时获取刷新的JWT。必须指定refresh_token参数的值。
  • client_credentials,获取服务器JWT。必须指定client_idclient_secret参数的值。
client_id
required
string

您的应用程序ID。此参数的值取决于grant_type参数的值:

请注意,client_secretclient_id参数的值应该来自同一客户端。

refresh_token
string

在响应此调用(其中grant_type参数中的值为authorization_coderefresh_token)的最后一个请求时收到的此参数的值。如果grant_type=refresh_token则为必需

client_secret
string

您的密钥。此参数的值取决于grant_type参数的值:

  • 如果是authorization_code,则创建OAuth 2.0客户端并使用其密钥。 如果创建了具有机密认证类型的OAuth 2.0客户端,此参数为必需
  • 如果是client_credentials,请联系您的客户成功经理来创建服务器OAuth 2.0客户端并获取其密钥。 对于该客户端类型,此参数为必需

请注意,client_secretclient_id参数的值应该来自同一客户端。

redirect_uri
string
code
string

交换给JWT的认证代码。如果grant_type=authorization_code则为必需

code_verifier
string

用于PKCE请求的代码验证器(应用程序最初在授权请求之前生成)。

Responses
200

确定

400

错误的请求

404

未找到

418

我是茶壶

422

无法处理的实体

429

请求过多

Request samples
application/x-www-form-urlencoded
refresh_token=string&grant_type=string&client_secret=string&client_id=string&redirect_uri=string&code=string&code_verifier=string
Response samples
application/json
{
  • "access_token": "2YotnFZFEjr1zCsicMWpAA",
  • "expires_in": 3600,
  • "refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA",
  • "scope": "email user_profile",
  • "token_type": "bearer"
}