现场开发需求场景:请求webapi,返回苍穹待办的url,第三方直接访问url会跳转登录页面,需要自动跳过登录页展示url。
1、获取AppToken
url:http://127.0.0.1:8080/ierp/api/getAppToken.do
请求参数:
{
"appId": "demo",
"appSecuret": "demo",
"tenantid": "hq_cosmic",
"accountId": "679008189806542848",
"language": "zh_CN"
}
返回参数:
{
"data": {
"app_token": "454fd514-1f65-4288-b6e1-4e117fa99b00",
"success": true,
"error_desc": "",
"expire_time": 1602850643709,
"error_code": "0"
},
"state": "success"
}
2、获取access_token
url:http://127.0.0.1:8080/ierp/api/login.do
请求参数:
{
"user": "18800110089",
"apptoken": "73b81753-5e08-486e-bd1a-b9ebe15aece9",
"accountId": "679008189806542848",
"usertype": ""
}
返回参数:
{
"data": {
"access_token": "PqOQtYY8OKZppwvCfq1PFQJtPMIBK3fGDgfsjVykL4AUUnQr5q3YELWwY9a9rYwYtkUBZte2dLu2q7oaaTB83ek9UMua3EcU23LXHKnaY7WdG6zgc6nRyOYQEWzda2Ao",
"success": true,
"error_desc": "",
"expire_time": 1602850601267,
"error_code": "0"
},
"state": "success"
}
3、请求webapi接口
请求参数:
{
"userid": "ID-000001",
"start": 0,
"end": 1,
"contentType": "1",
"searchString": ""
}
返回参数:
{
"success": true,
"data": {
"total": 16,
"data": [
{
"createtime": "2020-10-16 15:00:56",
"comments": "3",
"qcusername": "张博",
"ifatt": "",
"actionurl": "http://localhost:8080/ierp/integration/yzjShareOpen.do?formId=wf_approvalpage_bac&mb_formId=wf_approvalpagemobile_bac&pkId=1003542850039711744&src=wf&accountId=679008189806542848&taskId=1003543069015936000&type=toHandle&tId=1003543069015936000",
"todoid": 1003543069015936000,
"title": "单据编号:changeapply-00000021",
"userid": 924615816001883136
}
]
},
"errorCode": "success"
}
4、第三方请求苍穹web页面
请求accessTokenLogin.do方法,携带三个参数access_token,encode和redirect参数
url:http://127.0.0.1:8080/ierp/accessTokenLogin.do?access_token=tUmw8IX797BzHrEcOwFVRDKss2VYDZRfzNuTHnQKyH7cMTC2kc7OCnLrl4MRS9kRSn3uAh4SEE8Jwuisl7aEr32MaH2bCPQtNq14aVBki9SqIbHlkDoFpb5s94RpFu7h&encode=true&redirect=http%3A%2F%2F127.0.0.1%3A8080%2Fierp%2Fintegration%2FyzjShareOpen.do%3FformId%3Dwf_approvalpage_bac%26mb_formId%3Dwf_approvalpagemobile_bac%26pkId%3D1003542850039711744%26src%3Dwf%26accountId%3D679008189806542848%26taskId%3D1003543069015936000%26type%3DtoHandle%26tId%3D1003543069015936000
即可通过accessTokenLogin+access_token+encode后的redirect地址,即可实现第三方请求苍穹web页面。
注意:请求的accessTokenLogin.do这个接口的地址localhost:8080/ierp/,和redirect重定向的地址localhost:8080/ierp/,必须和苍穹配置的domain.contextUrl一致,这点很重要不然会报redirect 参数不符合安全要求!
推荐阅读