@heybox/hb-sdk API Reference - v0.9.5
    正在准备搜索索引...

    接口 LoginResult

    小程序服务端用于换取当前用户身份的短期授权码。

    页面应立即把 code 通过 HTTPS 提交给开发者自己的服务端;服务端再使用仅保存在 服务端的应用凭据换取 OpenAPI token。不要把结果写入 DOM、日志、localStorage 或其他 持久化存储,也不要把 code 当作 app_user_id 或业务 session 使用。

    interface LoginResult {
        accountKey?: string;
        code: string;
        expiresIn: number;
        scopes: ("identity" | "profile" | "steam_account")[];
    }
    索引

    属性

    accountKey?: string

    与 code 对应的本地账号标识。旧 Host 可能缺失;它不是用户 ID 或服务端认证凭据。

    code: string

    一次性短期授权码。

    该不透明字符串只属于当前小程序,提交给开发者服务端并成功换票后立即失效。过期、 重复使用或提交给其他小程序都会换票失败;此时应由新的明确用户操作再次调用 auth.login(),不要重试或解析旧 code。

    expiresIn: number

    授权码剩余有效期,单位为秒。

    返回值是正整数;当前服务端通常返回 300,但调用方必须以本字段为准并尽快换票, 不要把 300 硬编码为长期契约。该值不是换票后 access token 或业务 session 的有效期。

    scopes: ("identity" | "profile" | "steam_account")[]

    本次授权码实际包含的 scope。

    数组无重复项且始终包含 identity。它可能少于 LoginOptions.scopes 中请求的 scope;只有这里实际包含 profile 时,服务端才应读取或依赖昵称、头像字段。