# 服务端接口code2session

# 功能描述

校验小游戏前端通过 ks.login 接口获取的临时登录凭证 code,若合法则返回会话密钥 session_key 、open_id 等字段。

# Server API

Method: POST

URL: https://game.kwai.com/openapi/login/code2session

Query Params

属性 类型 说明
app_id string 从快手开放平台获取的 app_id
app_secret string 从快手开放平台获取的 app_secret
code string login登录接口返回的字段

POST Body

Content-Type: application/x-www-form-urlencoded

Body:空


请求举例: https://game.kwai.com/openapi/login/code2session?app_id=APPID&app_secret=APPSECRET&code=XXX


响应

Content-Type: application/json

名称 类型 说明
result int 1:成功,100:参数不完整,240002:app_secret非法,240001:code非法
open_id string 快手海外小游戏用户唯一标识
session_key string 会话密钥
union_id string 关联同一个开发者不同游戏的同一用户的唯一标识,详见 UnionID 机制说明