OpenAccount使用指南

更新时间:2018-05-16 16:14:38

服务简介

账号及用户服务属于共享接入平台提供的官方服务之一,基于阿里集团的OpenAccount(简称OA)服务实现,主要用于帮助开发者快速搭建自有用户体系,实现账号登录、注册、用户管理等功能。开发者在完成接入平台入驻后,服务自动开启。
一期仅支持PC WEB账号体系搭建

开发流程:

开发步骤

1.在开放平台注册应用,获取Appkey,AppSecret,AccessKey(AK)
2.通过iotxAccountSyncApp接口将Appkey信息同步至OA
3.参考PC Web开发流程完成iframe配置及登录页面开发

开发流程图

账密登录

嵌入登录iframe页面 + 页面监听换绑成功回调消息

<div class="content" data-spm="2">
<input type="hidden" id="isTMSExist" value="true" >
    <div id="register-module" class="alibaba-register">
        <div id="alibaba-login-iframe">
            <div id="alibaba-login-iframe-loading"></div>
        </div>
    </div>
</div>

<script type="text/javascript" charset="utf-8" src="https://f.alicdn.com/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="https://g.alicdn.com/vip/open-account/0.4.5/js/mini-login-embedderV3.js"></script>
<script>
    var miniLoginEmbedder = new window.MiniLoginEmbedder();
    miniLoginEmbedder.init({
        targetId    : 'alibaba-login-iframe',
        appKey : '替换成真实的appKey',
        iframeUrl   : 'https://login-openaccount.aliyun.com/login/mini_login.htm',
        lang:'zh_CN',
        notLoadSsoView: '',
        notKeepLogin: 'true',
        loginId: '',
        styleType: 'auto',
        loginIdPlaceHolder: '手机/邮箱',
        iframeWidth: '320px',
        loginButtonValue: '登录',
        addRegisterUrl: 'false',
        addResetPwdUrl: 'false',
        useQrcodeLogin: 'true',
        autotest: 'false'
    });

    miniLoginEmbedder.addEvent('onMessage', function(args) {
        //监听登录完成后的消息: args.action == "loginResult"
        if(args.action && args.action == "loginResult" && args.resultCode=='100') {
            location.href = "loginSuccess.htm"; //应用回跳地址
            // args包含以下属性:
            // args.action: 固定为"loginResult"
            // args.resultCode: 固定为100, 代表成功, 登录不成功不会发送事件.
            // args.loginId: 为用户登录框中填写的登录外标, 可能为"登录手机", "登录邮箱", "登录昵称"
            // args.token: 为用户登录完成后openaccount颁发的一次性token, 可以根据该token调用createSessionByAuthCode服务验证token, 拿到登录用户id、iotToken等信息
        }

        // 当嵌入iframe时将addRegisterUrl属性设置为true时才需要监听注册消息
        // 监听注册消息: args.action == "register"
        if(args.action && args.action == "register" && args.resultCode=='100'){
            // args包含以下属性:
            // args.action: 固定为register"
            location.href = "register.htm"; // 请跳转到自己的注册页面
        }

        // 当嵌入iframe时将addResetPwdUrl属性设置为true时才需要监听找密消息
        // 监听找密消息: args.action == "resetpwd"
        if(args.action && args.action == "resetpwd" && args.resultCode=='100'){
            location.href = "findpwd.htm"; // 请跳转到自己的找密页面
        }
    });
</script>

通过 OpenAccount 颁发的一次性 token 换 iotToken 和 identityId

以 nodejs 为例

const uuidv5 = require('uuid/v5');
const Client = require('aliyun-api-gateway').Client;
const client = new Client('appKey', 'appSecret');
const result = yield this.service.apigw.post('https://api.link.aliyun.com/account/createSessionByAuthCode', {
    data: {
        id: uuidv5('http://example.com/hello', uuidv5.URL);,
        version: '1.0',
        request: {
            apiVer: '1.0.4',
        },
        params: {
            request: {
                authCode: oaToken,
                appKey: '换成你的appKey',
                loginSource: 'openAccount',
                authCodeType: 'TOKEN',
            },
        },
    },
});
console.log(result);
// {
//     "code": 200,
//     "data": {
//         "identityId": "xxx",
//         "iotToken": "xxxx",
//         "refreshToken": "xxx",
//         "iotTokenExpire":72000,
//         "refreshTokenExpire":720000
//     },
//     "id":"a2845614-7156-42ff-94f7-9bc8db03bfa1"
// }

通过 identityId 获取用户信息

const uuidv5 = require('uuid/v5');
const Client = require('aliyun-api-gateway').Client;
const client = new Client('appKey', 'appSecret');
const result = yield this.service.apigw.post('https://api.link.aliyun.com/account/queryIdentityList', {
    data: {
        id: uuidv5('http://example.com/hello', uuidv5.URL);,
        version: '1.0',
        request: {
            apiVer: '1.0.4',
        },
        params: {
            request: {"identityIds":["xxx"]}
        },
    },
});
console.log(result);
/*
{
  "code": 200,
  "data": [
    {
      "gmtModified": 1523843487000,
      "loginId": "xx",
      "gender": null,
      "avatarUrl": null,
      "nickName": "xxx",
      "modifier": null,
      "gmtCreate": 1523539074000,
      "lastLoginTime": 1523843487000,
      "phone": "xxx",
      "identityId": "xxx",
      "loginName": "",
      "tenantId": "xxx",
      "creater": null,
      "email": "xxx",
      "loginSource": "openAccount"
    }
  ],
  "message": "success",
  "class": "com.aliyun.iotx.common.base.service.IoTxResult"
}

*/

手机+邮箱注册:

前端代码:

<form action="/account/register" method="post">
    <div class="form-group">
        <label for="name"><span class="required">*</span> 登录邮箱 </label>
        <input type="text" id="login_email" name="login_email" value="" class="form-control" required>
    </div>
     <div class="form-group">
        <label for="name"><span class="required">*</span> 手机号 </label>
        <input type="text" id="login_phone" name="login_phone" value="" class="form-control" required>
    </div>
    <div class="form-group">
        <label for="name"><span class="required">*</span> 登录密码 </label>
        <input type="password" id="login_passwd" name="login_passwd" value="" class="form-control" required>
    </div>
    <div class="form-group">
        <label for="name"><span class="required">*</span> 重复登录密码 </label>
        <input type="password" id="login_passwd2" name="login_passwd2" value="" class="form-control" required>
    </div>

    <button type="submit" name="__save__" value="on" class="btn btn-default">提交</button>
</form>

服务端代码(NodeJS)

const uuidv5 = require('uuid/v5');
const Client = require('aliyun-api-gateway').Client;
const client = new Client('appKey', 'appSecret');
const result = yield this.service.apigw.post('https://api.link.aliyun.com/account/registerAccount', {
    data: {
        id: uuidv5('http://example.com/hello', uuidv5.URL);,
        version: '1.0',
        request: {
            apiVer: '1.0.4',
        },
        params: {
            request: {
                accountMetaV2:{
                    password: "", // 密码
                    avatarUrl: "", // 头像,可为空
                    nickName: "", //昵称
                    loginName: "", // 登录名
                    phone: "", // 登录的手机号
                    email: "", // 登录的邮箱,登录名/登录手机号/登录邮箱三者必须至少有一个,也可以都有
                    appKey: ""
                }
            }
        },
    },
});
console.log(result);

手机找密:

嵌入找密iframe页面 + 页面监听换绑成功回调消息

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>云账号-帐号改密</title>
</head>

<body>
<div>
    <div id="login-module">
        <div id="alibaba-findpwd-iframe">
            <div id="alibaba-login-iframe-loading"></div>
        </div>
    </div>
</div>
<script type="text/javascript" charset="utf-8" src="https://g.alicdn.com/vip/open-account/0.1.1/js/mini-login-embedderV3.js"></script>
<script>
    var miniLoginEmbedder = new window.MiniLoginEmbedder();
    miniLoginEmbedder.addEvent('onMessage', function(args) {
        //监听找密完成的消息
        if(args.action && args.action == "findpwd"&&args.resultCode=='100'){
            alert('找密成功');
            window.location.href = "/";
        }
        //监听切换邮箱找密的消息
        if(args.action && args.action == "resetPwdSwitch"&&args.resultCode=='100'){
            location.href = "/account/findpasswd/email" ; // 切换到邮箱找密的地址
        }
    });

    miniLoginEmbedder.init({
        targetId    : 'alibaba-findpwd-iframe',
        appKey : '换成你的appKey',
        iframeUrl   : 'https://login-openaccount.aliyun.com/login/mini_findpwd.htm',
        lang:'zh_CN',
        loginId:'',
        iframeWidth:'800',
        iframeHeight:'350',
        addSwitchUrl: "true"
    });

</script>

</body>
</html>

邮箱找密码:

嵌入找密iframe页面 + 页面监听换绑成功回调消息

<html>
<head>
    <title>邮箱找密</title>
    <script type="text/javascript" charset="utf-8" src="https://g.alicdn.com/vip/open-account/0.1.4/js/mini-login-embedderV3.js"></script>
</head>
<body>
<div>
    <div id="login-module">
        <div id="alibaba-register-iframe">
            <div id="alibaba-login-iframe-loading"></div>
        </div>
    </div>
</div>

<script>
function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }
 var iFrameUrl = getQueryString('iFrameUrl')||'emailResetPwdStep1.htm';
        var emailToken = getQueryString('emailToken');
        var email = getQueryString('email');
    var miniLoginEmbedder = new window.MiniLoginEmbedder();

    miniLoginEmbedder.addEvent('onMessage', function(args) {
        //监听登录完成后的消息: args.action == "register"
        if(args.action && args.action == "emailResetPwd" && args.resultCode=='100') {
            location.href = "findpwdSuccess.do?appKey=4272&phone=" +args.phone + "&token=" + encodeURIComponent(args.token);
            // args包含以下属性:
            // args.action: 固定为"findpwd"
            // args.resultCode: 固定为100, 代表成功, 注册不成功不会发送事件.
            // args.email: 为用户注册框中填写的登录邮箱
            // args.token: 为用户注册完成后openaccount颁发的一次性token, 可以根据该token调用openaccount服务验证token, 拿到注册成功用户id等信息
        }
         //监听切换邮箱找密的消息
        if(args.action && args.action == "resetPwdSwitch"&&args.resultCode=='100'){
            location.href = "/account/findpasswd/phone" ; // 切换到邮箱找密的地址
        }
    });

    miniLoginEmbedder.init({
        targetId    : 'alibaba-register-iframe',
        appKey : '换成你的appKey',
        iframeUrl   : 'https://login-openaccount.aliyun.com/login/' + iFrameUrl,
        lang:'zh_CN',
        loginId:'test',
        iframeWidth:'800',
        iframeHeight:'350',
        hostUrl: window.location.href, // 邮件中重新设置新密码的链接地址
        emailToken: emailToken,
        email: email // 默认的找回邮箱地址
    });

</script>
</body>
</html>

其他服务端API列表:

API名称 说明
iotxAccountRegisterAccount 注册账号
iotxAccountModifyAccount 修改账号
iotxAccountUnRegisterAccount 注销账号
iotxAccountCheckAccountRegistered 查询账号是否已经注册
iotxAccountFreezeAccount 冻结账号
iotxAccountModifyPassword 修改密码
iotxAccountCreateAttr 创建属性
iotxAccountUpdateAttr 修改属性
iotxAccountDeleteAttr 删除属性
iotxAccountListAttr 查询属性(不分页)
iotxAccountCreateSession 创建session
iotxAccountAuthSession 验证session
iotxAccountCheckOrCreateSession 检查并创建会话
iotxAccountRefreshSession 刷新统一会话
iotxAccountInvalidSession 失效统一会话
iotxAccountCreateSessionByOaAuthCode 通过OAToken或SessionId创建会话
iotxAccountCreateSessionByAuthCode 通过authCode获取iot会话
iotxAccountRegisterIdentity 注册统一身份
iotxAccountRegisterIdentityByToken 通过三方token注册统一身份
iotxAccountQueryIdentity 根据loginId&loginSource查询统一身份
iotxAccountCheckOrRefreshSession 通过refreshToken换iotToken
iotxAccountQueryIdentityByPage 根据租户ID和隔离ID,分页查询该住户下的用户信息
iotxAccountSyncApp 同步应用信息至OA

API对接文档:

注册账号

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/registerAccount 1.0.0 注册OA账号同时注册统一身份

请求参数

参数 类型 必填 描述
accountMetaV2 JSON 账号属性信息

accountMetaV2参数列表

参数 类型 必填 描述
phone String 手机号和邮箱至少一个必填 手机号
email String 手机号和邮箱至少一个必填 邮箱
loginName String 登录名
password String 密码,6-20位长度
appKey String OA的appKey
nickName String 昵称
creater String 创建者
modifier String 修改者

返回参数

名称 类型 描述
data String 账号的身份ID

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"accountMetaV2":{"phone":"15757286621", "appKey":"60039075", "password":"taobao1234"}}
      },
      "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": "50e5opda16ebf5558e000a660ac9632a038c2479",
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

冻结账号

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/freezeAccount 1.0.0 冻结账号

请求参数

参数 类型 必填 描述
identityId String 要冻结的账号的身份ID

返回参数

名称 类型 描述

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"identityId":"50e5opda16ebf5558e000a660ac9632a038c2479"}
      },
      "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

修改账号

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/modifyAccount 1.0.0 修改账号属性

请求参数

参数 类型 必填 描述
identityId String 要修改的账号的身份ID
accountMetaV2 JSON 是账号属性信息

accountMetaV2参数列表

参数 类型 必填 描述
phone String 手机号和邮箱至少一个必填 手机号
email String 手机号和邮箱至少一个必填 邮箱
loginName String 登录名
password String 密码,6-20位长度
appKey String OA的appKey
nickName String 昵称
creater String 创建者
modifier String 修改者

返回参数

名称 类型 描述

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"identityId":"50e5opda16ebf5558e000a660ac9632a038c2479", "accountMetaV2":{"phone":"15757286621", "appKey":"60039075","nickName":"test"}}
      },
      "version": "1.0"
}

正常返回示例

{"code":200,"data":"","id":"a2845614-7156-42ff-94f7-9bc8db03bfa1"}

修改密码

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/modifyPassword 1.0.0 修改密码

请求参数

参数 类型 必填 描述
identityId String 要修改的账号的身份ID
appKey String OA的appKey
password String 登陆密码

返回参数

名称 类型 描述

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"identityId":"50e5opda16ebf5558e000a660ac9632a038c2479","appKey":"60039075","password":"tst1234"}
      },
      "version": "1.0"
}

正常返回示例

{"code":200,"data":"","id":"a2845614-7156-42ff-94f7-9bc8db03bfa1"}

根据OA token注册统一身份

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/registerIdentityByToken 1.0.0 根据OA token注册统一身份

请求参数

参数 类型 必填 描述
token String OA token
loginSource String 账号来源,目前为openAccount
appKey String OA appKey

返回参数

名称 类型 描述
data String 账号的身份ID

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"token":"ancsdfkd","loginSource":"openAccount", "appKey":"appkey1"}
      },
      "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": "506bop1ef3a1ce8005d731e0df57ae175ac94618",
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

注销账户

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/unRegisterAccount 1.0.0 注销账户

请求参数

参数 类型 必填 描述
identityId String 要注销的账号的身份ID
appKey String OA的appKey

返回参数

名称 类型 描述

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"identityId":"50e5opda16ebf5558e000a660ac9632a038c2479","appKey":"appKkey1"}
      },
      "version": "1.0"
}

正常返回示例

{"code":200,"data":"","id":"a2845614-7156-42ff-94f7-9bc8db03bfa1"}

通过authCode成iotToken

定义描述

path 版本 描述 是否需要cloudToken
http://domain/account/createSessionByAuthCode 1.0.0 通过authCode成iotToken

请求参数

参数 类型 必填 描述
authCode String OA sessionId、token以及三方的authToken,统称为authCode
accountType String 当前支持的值"OA_SESSION"或"OA_TOKEN"
appKey String 业务方账号的appKey
registerPlatform String 注册平台

返回参数

名称 类型 描述
identityId String 账号的身份ID
iotToken String iotToken
refreshToken String refreshToken
iotTokenExpire String iotToken有效时长,单位:秒
refreshTokenExpire String refreshToken有效时长,单位:秒

示例

请求示例

{
      "request": {
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"authCode":"sdfsdfsdf","appKey":"iuerierert","accountType":"OA_SESSION"}
      },
      "version": "1.0"
    }

正常返回示例

{
    "code": 200,
    "data": {
        "identityId": "50f2op52a61e7de2f741cce66eaac900fd071323",
        "iotToken": "267f8002434befa742b302871dde18a8",
        "refreshToken": "4DF38E239EA0B9D5A6B04D5262D9C15F",
        "iotTokenExpire":72000,
        "refreshTokenExpire":720000
    },
    "id":"a2845614-7156-42ff-94f7-9bc8db03bfa1"
}

通过refreshToken获取iotToken

定义描述

path 版本 描述 是否需要cloudToken
http://domain/account/checkOrRefreshSession 1.0.0 通过refreshToken获取iotToken

请求参数

参数 类型 必填 描述
identityId String 账号的身份ID
refreshToken String refreshToken

返回参数

名称 类型 描述
identityId String 账号的身份ID
iotToken String iotToken
refreshToken String refreshToken
iotTokenExpire String iotToken有效时长,单位:秒
refreshTokenExpire String refreshToken有效时长,单位:秒

示例

请求示例

{
      "request": {
         "apiVer": "1.0.0"
      },
      "params": {
        "request": {"refreshToken":"267f8002434befa742b302871dde18a8","identityId":"50f2op52a61e7de2f741cce66eaac900fd071323"}
      },
      "version": "1.0"
    }

正常返回示例

{
    "code": 200,
    "data": {
        "identityId": "50f2op52a61e7de2f741cce66eaac900fd071323",
        "iotToken": "267f8002434befa742b302871dde18a8",
        "refreshToken": "4DF38E239EA0B9D5A6B04D5262D9C15F",
        "iotTokenExpire":72000,
        "refreshTokenExpire":720000
    },
   "id":"a2845614-7156-42ff-94f7-9bc8db03bfa1"
}

验证session

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/authSession 1.0.0 验证session

请求参数

参数 类型 必填 描述
identityId String 账号的身份ID
iotToken String iotToken

返回参数

名称 类型 描述
gmtModified String 修改时间
loginId String 登录ID
gmtCreate String 创建时间
phone String 手机
identityId String 账号的身份ID
loginName String 登录名
email String 邮箱
loginSource String loginSource

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"identityId":"50e5opda16ebf5558e000a660ac9632a038c2479","iotToken":"322AD610F580652C2BB9A7DE73F59F38"}
      },
      "version": "1.0"
}

正常返回示例

{
    "code":200,
    "data":{
        "gmtModified":1511163286000,
        "loginId":"4398050074974",
        "gmtCreate":1511163286000,
        "phone":"15111632858",
        "identityId":"50adopfb59ddd63a6b968fa4890f85150c877950",
        "loginName":"DNXVRYY7Z45WS9QP1MVH",
        "email":"15111632858@mail.com",
        "loginSource":"openAccount"
    },
    "id":"0ffbc67c-fe1f-424f-a23f-65894d89e8a3"u
}

检查账号是否已注册

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/checkAccountRegistered 1.0.0 检查账号是否已注册

请求参数

参数 类型 必填 描述
phone String 手机号和邮箱至少一个必填 手机号
email String 手机号和邮箱至少一个必填 邮箱
appKey String OA的appKey

返回参数

名称 类型 描述
data boolean 是否已注册

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"phone":"15757286621", "appKey":"60039075"}
      },
      "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": true,
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

检查并创建会话

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/checkOrCreateSession 1.0.0 检查账号是否已注册

请求参数

参数 类型 必填 描述
identityId String 账号的身份ID
iotToken String iotToken

返回参数

名称 类型 描述
identityId String 账号的身份ID
iotToken String iotToken
refreshToken String refreshToken

示例

请求示例

{
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"iotToken":"267f8002434befa742b302871dde18a8","identityId":"50f2op52a61e7de2f741cce66eaac900fd071323"}
      },
      "version": "1.0"
    }

正常返回示例

{
    "code": 200,
    "data": {
        "identityId": "50f2op52a61e7de2f741cce66eaac900fd071323",
        "iotToken": "267f8002434befa742b302871dde18a8",
        "refreshToken": "4DF38E239EA0B9D5A6B04D5262D9C15F"
    },
   "id":"a2845614-7156-42ff-94f7-9bc8db03bfa1"
}

创建Session

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/createSession 1.0.0 创建Session

请求参数

参数 类型 必填 描述
identityId String 账号的身份ID

返回参数

名称 类型 描述
identityId String 账号的身份ID
iotToken String iotToken
refreshToken String refreshToken

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"identityId":"50e5opda16ebf5558e000a660ac9632a038c2479"}
      },
      "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": {
        "identityId": "50e5opda16ebf5558e000a660ac9632a038c2479",
        "iotToken": "dcb87fe58b0f248abef96c08aed36d6b",
        "refreshToken": "322AD610F580652C2BB9A7DE73F59F38"
    },
     "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

通过OA Token或SessionId创建会话

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/createSessionByOaAuthCode 1.0.0 通过OA Token或SessionId创建会话

请求参数

参数 类型 必填 描述
authCode String OA登陆后获得的token或sessionId
authCodeType String TOKEN 或SESSION
appKey String OA的appKey
loginSource String openAccount

返回参数

名称 类型 描述
identityId String 账号的身份ID
iotToken String iotToken
refreshToken String refreshToken

示例

请求示例

{
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"authCode":"sdfsdfsdf","appKey":"iuerierert","loginSource":"openAccount","authCodeType":"TOKEN"}
      },
      "version": "1.0"
    }

正常返回示例

{
    "code": 200,
    "data": {
        "identityId": "50f2op52a61e7de2f741cce66eaac900fd071323",
        "iotToken": "267f8002434befa742b302871dde18a8",
        "refreshToken": "4DF38E239EA0B9D5A6B04D5262D9C15F"
    },
    "id":"a2845614-7156-42ff-94f7-9bc8db03bfa1"
}

失效统一会话

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/createSessionByOaAuthCode 1.0.0 失效统一会话

请求参数

参数 类型 必填 描述
identityId String 账号的身份ID
iotToken String iotToken

返回参数

名称 类型 描述

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"identityId":"50e5opda16ebf5558e000a660ac9632a038c2479","iotToken":"322AD610F580652C2BB9A7DE73F59F38"}
      },
      "version": "1.0"
}
      "version": "1.0"
    }

正常返回示例

{
   {"code":200,"data":"","id":"a2845614-7156-42ff-94f7-9bc8db03bfa1"}
}

根据loginId & loginSource查询统一身份

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/queryIdentity 1.0.0 根据loginId & loginSource查询统一身份

请求参数

参数 类型 必填 描述
loginId String OA loginId
loginSource String 账号来源,目前为openAccount
opType int 查询类别,1-根据loginId & loginSource;2-根据号码;3-根据邮箱;其他非法

返回参数

名称 类型 描述
identityId String 账号的身份ID
loginId String OA loginId
loginSource String 账号来源
gmtCreate long 创建时间
gmtModified long 修改时间
loginName String 登陆名
phone String 号码
email String 邮箱
nickName String 昵称

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"loginId":"4398047084811","loginSource":"openAccount","opType":1}
      },
      "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": {
        "gmtModified": 1508314232000,
        "loginId": "4398047084811",
        "gmtCreate": 1508314232000,
        "identityId": "506bop1ef3a1ce8005d731e0df57ae175ac94618",
        "loginSource": "openAccount"
    },
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

刷新session

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/refreshSession 1.0.0 刷新session

请求参数

参数 类型 必填 描述
identityId String 账号的身份ID
refreshToken String refreshToken,用于重刷iotToken

返回参数

名称 类型 描述
identityId String 账号的身份ID
iotToken String iotToken
refreshToken String refreshToken

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"identityId":"50e5opda16ebf5558e000a660ac9632a038c2479","refreshToken":"322AD610F580652C2BB9A7DE73F59F38"}
      },
      "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": {
        "identityId": "50e5opda16ebf5558e000a660ac9632a038c2479",
        "iotToken": "7b334eec418d0d21f54596572f7918f5",
        "refreshToken": "322AD610F580652C2BB9A7DE73F59F38"
    },
     "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"

}

同步应用信息

定义描述

path 版本 描述 是否需要cloudToken
http://domain/account/syncApp 1.0.0 同步应用信息

请求参数

参数 类型 必填 描述
clientType String 客户端类型:PC,H5,ANDROID,IOS
appKey String 应用appKey
appName String 应用名称:字母或汉字开头,4-15个字符
description String 应用描述

返回参数

名称 类型 描述
data boolean 是否已同步

示例

请求示例

{
      "id":1508231990884,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"clientType":"PC","appName":"app1terst1","description":"测试应用1","appKey":"appkey1"}
      },
      "version": "1.0"
}

正常返回示例

{
    "code":200,
    "data":true,
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

创建属性

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/createAttr 1.0.0 创建属性

请求参数

参数 类型 必填 描述
attrKey String 属性key
attrType String 属性类型,目前只支持:INTEGER,STRING,DOUBLE
attrNameCn String 属性字段中文名称
attrExtra String 属性字段额外数据,暂无用
description String 说明描述
category Byte 0:系统属性,1:自定义属性
creator String 创建者
editor String 修改者
isActived Byte 是否启用,0:未启用;1:启用
showWhenRegister List 在各个端注册时是否显示
clientType String 客户端类型: PC, H5, IOS, ANDROID
show String 是否显示

返回参数

名称 类型 描述
data boolean 是否已创建

示例

请求示例

{
    "request": {
    "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
    "apiVer": "1.0.0"
    },
    "id": 1508212818676,
    "params": {
        "request": {
            "attrDTO":{
                "attrKey":"testAttr1",
                "attrType":"STRING",
                "attrNameCn":"属性名字",
                "description":"testDescription!",
                "attrExtra":"",
                "category":1,
                "creator":"",
                "editor":"",
                "isActived":1,
                "showWhenRegister":[{
                    "clientType":"PC",
                    "show":true
                }]
            }
        }
    },
    "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": true,
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

修改属性

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/updateAttr 1.0.0 修改属性

请求参数

参数 类型 必填 描述
attrKey String 属性key
attrType String 属性类型,目前只支持:INTEGER,STRING,DOUBLE
attrNameCn String 属性字段中文名称
attrExtra String 属性字段额外数据,暂无用
description String 说明描述
category Byte 0:系统属性,1:自定义属性
creator String 创建者
editor String 修改者
isActived Byte 是否启用,0:未启用;1:启用
showWhenRegister List 在各个端注册时是否显示
clientType String 客户端类型: PC, H5, IOS, ANDROID
show String 是否显示

返回参数

名称 类型 描述
attrKey String 属性key
attrType String 属性类型,目前只支持:INTEGER,STRING,DOUBLE
attrNameCn String 属性字段中文名称
attrExtra String 属性字段额外数据,暂无用
description String 说明描述
category Byte 0:系统属性,1:自定义属性
creator String 创建者
editor String 修改者
isActived Byte 是否启用,0:未启用;1:启用
showWhenRegister List 在各个端注册时是否显示
clientType String 客户端类型: PC, H5, IOS, ANDROID
show String 是否显示

示例

请求示例

{
    "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
    },
    "id": 1508212818676,
    "params": {
        "request": {
            "attrDTO":{
                "attrKey":"testAttr1",
                "attrType":"STRING",
                "attrNameCn":"属性名字2",
                "description":"testDescription2!",
                "attrExtra":"",
                "category":1,
                "creator":"",
                "editor":"",
                "isActived":1,
                "showWhenRegister":[{
                    "clientType":"PC",
                    "show":false
                }]
            }
        }
    },
    "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": {
        "editor": "",
        "showWhenRegister": [
            {
                "clientType": "PC",
                "show": false
            },
            {
                "clientType": "H5",
                "show": false
            },
            {
                "clientType": "ANDROID",
                "show": false
            },
            {
                "clientType": "IOS",
                "show": false
            }
        ],
        "gmtModified": 1508402668000,
        "creator": "",
        "isActived": 1,
        "attrKey": "testAttr1",
        "description": "testDescription2!",
        "attrExtra": "",
        "gmtCreate": 1508402668000,
        "attrType": "STRING",
        "attrNameCn": "属性名字2",
        "category": 1
    },
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

删除属性

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/deleteAttr 1.0.0 删除属性

请求参数

参数 类型 必填 描述
attrKey String 属性字段标识

返回参数

名称 类型 描述
data boolean 是否已删除

示例

请求示例

{
    "request": {
    "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
    "apiVer": "1.0.0"
    },
    "id": 1508212818676,
    "params": {
        "request": {
            "attrKey":"testAttr1"
        }
    },
    "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": true,
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

查询属性

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/listAttr 1.0.0 查询属性

请求参数

参数 类型 必填 描述
isActived 是否启用 不填:查询所有可用的属性(包括系统属性和用户自定义属性,包括已启用的和未启用的);0:查询未启用的属性;1:查询已启用的属性.

返回参数

名称 类型 描述
attrKey String 属性key
attrType String 属性类型,目前只支持:INTEGER,STRING,DOUBLE
attrNameCn String 属性字段中文名称
attrExtra String 属性字段额外数据,暂无用
description String 说明描述
category Byte 0:系统属性,1:自定义属性
creator String 创建者
editor String 修改者
isActived Byte 是否启用,0:未启用;1:启用
showWhenRegister List 在各个端注册时是否显示
clientType String 客户端类型: PC, H5, IOS, ANDROID
show String 是否显示

示例

请求示例

{
    "request": {
    "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
    "apiVer": "1.0.0"
    },
    "id": 1508212818676,
    "params": {
        "request": {
            "isActived":1
        }
    },
    "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": [
        {
            "showWhenRegister": [
                {
                    "clientType": "PC",
                    "show": false
                },
                {
                    "clientType": "H5",
                    "show": false
                },
                {
                    "clientType": "ANDROID",
                    "show": false
                },
                {
                    "clientType": "IOS",
                    "show": false
                }
            ],
            "editor": "",
            "gmtModified": 1508402972000,
            "creator": "",
            "isActived": 1,
            "attrKey": "testAttr1",
            "description": "testDescription2!",
            "attrExtra": "",
            "gmtCreate": 1508402668000,
            "attrType": "STRING",
            "attrNameCn": "属性名字2",
            "category": 1
        }
    ],
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

根据租户ID和隔离ID,分页查询该住户下的用户信息

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/queryIdentityByPage 1.0.0 根据租户ID和隔离ID,分页查询该住户下的用户信息

请求参数

参数 类型 必填 描述
offset int 查询偏移量
count int 查询数量

返回参数

名称 类型 描述
identityId String 账号的身份ID
loginId String OA loginId
loginSource String 账号来源
gmtCreate long 创建时间
gmtModified long 修改时间
loginName String 登陆名
phone String 号码
email String 邮箱
nickName String 昵称

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"offset":0, "count":1}
      },
      "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": [
        {
            "gmtModified": 1508314232000,
            "loginId": "4398047084811",
            "gmtCreate": 1508314232000,
            "identityId": "506bop1ef3a1ce8005d731e0df57ae175ac94618",
            "loginSource": "openAccount"
        }
    ],
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

注册统一身份

定义描述

path 版本 描述 是否需要cloudToken
http://domain/iotx/account/registerIdentity 1.0.0 注册统一身份

请求参数

参数 类型 必填 描述
loginId String OA loginId
loginSource String 账号来源,目前为openAccount
loginName String 登陆名
phone String 手机号
email String 邮箱
nickName String 账号可配置昵称
oauthType String 如果为OA对接的OAUTH,该选项有意义,其它忽略
creater String 创建者
modifier String 修改者

返回参数

名称 类型 描述
data String 账号的身份ID

示例

请求示例

{
     "id":1508232047194,
      "request": {
        "iotToken": "109049c80bcde4c06b15f6f62e29a3ba",
        "apiVer": "1.0.0"
      },
      "params": {
        "request": {"loginId":"4398047084811","loginSource":"openAccount"}
      },
      "version": "1.0"
}

正常返回示例

{
    "code": 200,
    "data": "506bop1ef3a1ce8005d731e0df57ae175ac94618",
    "id":"bb179e80-39fd-4a79-ba97-48ca87a3f5c5"
}

results matching ""

    No results matching ""