代码已开源,戳这里: https://github.com/YzzHa/eapp-corp-quick-start-python,赠人玫瑰手有余香,采纳的小伙伴们点个star再走呗 O.o
1. 登录验证流程分析,以Node为例
话不多说上代码,以关键代码为例, 部分密匙信息采用***进行占位,请对号入座。代码来自钉钉官方Node版QuickStart
// 获取用户信息
app.use('/login', function(req, res) {
// 获取access_token
HttpUtils.get("/gettoken", {
"appkey": config.appkey,
"appsecret": config.appsecret,
}, function(err, body) {
if (!err) {
var code = req.body.authCode;
var accessToken = body.access_token;
//获取用户id 依赖access_token
HttpUtils.get("/user/getuserinfo", {
"access_token": accessToken,
"code": code,
}, function(err2, body2) {
if (!err2) {
//获取用户详细信息 依赖userid
HttpUtils.get("/user/get", {
"access_token": accessToken,
"userid": body2.userid,
}, function(err3, body3) {
console.log(body2, body3);
if (!err3) {
res.send({
// 返回数据格式, 坑位预留
result: {