引用企业封装类库
SKIT.FlurlHttpClient.Wechat.Work
using Microsoft.AspNetCore.Mvc; using SKIT.FlurlHttpClient.Wechat.Work; using SKIT.FlurlHttpClient.Wechat.Work.Models; using SKIT.FlurlHttpClient.Wechat.Work.Settings;
实现代码
WechatWorkClientOptions options = new WechatWorkClientOptions(); //应用ID options.AgentId = 100001111; //应用密钥 options.AgentSecret = "7Gjeeffj5kvzJHK9_UstzP34uBCournb7jJ-rghneU"; //企业代码 options.CorpId = "ww882ff35521bfff1b"; //创建客户端 WechatWorkClient client = new WechatWorkClient(options); //建立AccessToken的request var request = new CgibinGetTokenRequest(); //根据request的参数得到结果 var response = client.ExecuteCgibinGetTokenAsync(request); //得到AccessToken string accessToken = response.Result.AccessToken;