赞
踩
获取凭证-获取企业accessToken(企业内部应用)
请求:
POST /v1.0/oauth2/accessToken HTTP/1.1
Host:api.dingtalk.com
Content-Type:application/json{
"appKey" : "String",
"appSecret" : "String"
}
返回:
HTTP/1.1 200 OK
Content-Type:application/json
{
"accessToken" : "fw8ef8we8f76e6f7s8dxxxx",
"expireIn" : 7200
}
请求:
get https://oapi.dingtalk.com/gettoken?appkey=ding1234&appsecret=abcdefg
返回:
{
"errcode": 0,
"access_token": "96fc7a7axxx",
"errmsg": "ok",
"expires_in": 7200
}
引用dingtalk.js
- import * as dd from 'dingtalk.js';
-
- let ddCorpId = 'xxxxxx';
- let ddCode = '';
-
- if (dd.env.platform !== 'notInDingTalk') {
- dd.ready(function() {
- dd.runtime.permission.requestAuthCode({
- corpId: ddCorpId,
- onSuccess: function(result) {
- ddCode = result.code;
- callback && callback(ddCode);
- },
- onFail: function(err) {
- errCalback && errCallback(err);
- }
- });
- });
-
- dd.error(function(error){
- alert({title:JSON.stringify(error)});
- });
- }else{
- alert({title:'请在钉钉中使用'});
- }
ddCode为获取到的免登码。
请求:
post https://oapi.dingtalk.com/topapi/v2/user/getuserinfo
返回:
{
"errcode": 0,
"result": {
"associated_unionid": "N2o5U3axxxx",
"unionid": "gliiW0piiii02zBUjUxxxx",
"device_id": "12drtfxxxxx",
"sys_level": 1,
"name": "张xx",
"sys": true,
"userid": "userid123"
},
"errmsg": "ok"
}
请求:
get https://oapi.dingtalk.com/user/getuserinfo
返回:
{
"errcode": 0,
"sys_level": 1,
"is_sys": true,
"name": "张xx",
"errmsg": "ok",
"deviceId": "12drtfxxxxx",
"userid": "user456"
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。