欢迎光临
我们一直在努力

九八云百度小程序教程:swan.getLoginCode

  • swan.getLoginCode
    • 方法参数
      • 返回参数说明
      • success 返回参数说明
      • 代码示例

    swan.getLoginCode

    基础库 3.230.1 版本开始支持。

    解释:获取宿主 App 登录凭证(Authorization Code)。

    方法参数

    Object object

    返回参数说明

    属性名 类型 必填 默认值 说明
    timeout Number 超时时间(单位:ms)
    success Function 接口调用成功的回调函数
    fail Function 接口调用失败的回调函数
    complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

    success 返回参数说明

    参数 类型 说明
    code String 用户登录凭证(有效期十分钟),开发者需要在开发者服务器后台调用 api,使用 code 换取 session_key 等信息。
    用户登录凭证 code 只能使用一次。

    代码示例

    • SWAN
    • JS
    
     
    1. <view class="wrap">
    2. <button type="primary" bindtap="getLoginCode">获取用户登录百度 APP 凭证</button>
    3. </view>
    
     
    1. Page({
    2. getLoginCode() {
    3. swan.getLoginCode({
    4. success: res => {
    5. console.log('getLoginCode success', res);
    6. },
    7. fail: err => {
    8. console.log('getLoginCode fail', err);
    9. }
    10. });
    11. }
    12. });

    赞(0) 打赏
    未经允许不得转载:九八云安全 » 九八云百度小程序教程:swan.getLoginCode

    评论 抢沙发