Request
| Basic information | |
|---|---|
| HTTP URL | https://api.dingtalk.io/topapi/v2/user/getuserinfo |
| HTTP Method | POST |
| Supported app types | appType-Internal appappType-Third-party enterprise app |
| Required permissions | permission-qyapi_base-Basic permissions required to call enterprise APIs |
Query parameters
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| access_token | String | Yes | 6ed1bxxx | The app credential used to call this API. - For an internal app, obtain it through the API to get the access_token of an internal app. - For a third-party enterprise app, obtain it through the API to get the access_token of a third-party enterprise. |
Request body
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| code | String | Yes | bab02f63c1e030fbbxxxx | The silent login authorization code. For how to obtain it, see: - Silent login authorization code for a mini program - Silent login authorization code for a micro app Note This authorization code is valid for 5 minutes and can be used only once. |
Request example
curl -X POST "https://api.dingtalk.io/topapi/v2/user/getuserinfo" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=417124xxxx2a3c270d5' \
-d 'code=123456'
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/v2/user/getuserinfo");
OapiV2UserGetuserinfoRequest req = new OapiV2UserGetuserinfoRequest();
req.setCode("bab02f63c1e030fbbxxxx");
OapiV2UserGetuserinfoResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
# -*- coding: utf-8 -*-
import dingtalk.api
req=dingtalk.api.OapiV2UserGetuserinfoRequest("https://api.dingtalk.io/topapi/v2/user/getuserinfo")
req.code="123456"
try:
resp= req.getResponse(access_token)
print(resp)
except Exception,e:
print(e)
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');
$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiV2UserGetuserinfoRequest;
$req->setCode("123456");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/v2/user/getuserinfo");
let { Config, OapiV2UserGetuserinfoParams, OapiV2UserGetuserinfoRequest } = require('./client.js');
let Client = require('./client.js').default
async function test() {
const config = new Config()
config.serverUrl = 'https://api.dingtalk.io/topapi/v2/user/getuserinfo'
config.session = 'access_token'
const params = new OapiV2UserGetuserinfoParams();
params.code = 'bab02f63c1e030fbbxxxx'
const request = new OapiV2UserGetuserinfoRequest()
request.params = params
const client = new Client(config)
try {
const res = await client.oapiV2UserGetuserinfo(request)
console.log(res.body)
} catch (err) {
console.log(err)
}
}
test()
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/v2/user/getuserinfo");
OapiV2UserGetuserinfoRequest req = new OapiV2UserGetuserinfoRequest();
req.Code = "123456";
OapiV2UserGetuserinfoResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
Response
Response body
| Name | Type | Example | Description |
|---|---|---|---|
| request_id | String | e8krly4vyiln | The request ID. |
| errcode | Number | 0 | The return code**.** |
| errmsg | String | ok | The text description of the return code. |
| result | UserGetByCodeResponse | The returned result. | |
| userid | String | user456 | The user ID of the user. |
| device_id | String | 12drtfxxxxx | The device ID. |
| sys | Boolean | true | Indicates whether the user is an admin. - true: Yes - false: No |
| sys_level | Number | 1 | The admin level. - 1: Super Admin - 2: Sub Admin - 100: Boss - 0: Other (such as a regular employee) |
| associated_unionid | String | N2o5U3axxxx | The unionId associated with the user. |
| unionid | String | gliiW002zUxxxx | The unionId of the user. |
| name | String | Zhang xx | The name of the user. |
Response body example
{
"errcode": 0,
"result": {
"associated_unionid": "N2o5U3axxxx",
"unionid": "gliiW0piiii02zBUjUxxxx",
"device_id": "12drtfxxxxx",
"sys_level": 1,
"name": "John Doe",
"sys": true,
"userid": "userid123"
},
"errmsg": "ok"
}