Пример #1
0
        /// <summary>
        /// 获取应用后台免登的accessToken 本接口获取的accessToken只在微应用后台管理免登服务中使用。
        /// </summary>
        /// <param name="corpId">企业Id</param>
        /// <param name="corpSecret">这里必须填写专属的SSOSecret</param>
        public OapiSsoGettokenResponse GetToken(string corpId, string corpSecret)
        {
            IDingTalkClient        client  = new DefaultDingTalkClient("https://oapi.dingtalk.com/sso/gettoken");
            OapiSsoGettokenRequest request = new OapiSsoGettokenRequest();

            request.Corpid     = corpId;
            request.Corpsecret = corpSecret;
            request.SetHttpMethod("GET");
            OapiSsoGettokenResponse response = client.Execute(request);

            return(response);
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static string GetDingSsoToken()
        {
            if (!string.IsNullOrWhiteSpace(token))
            {
                return(token);
            }

            IDingTalkClient        client = new DefaultDingTalkClient(dingUrl + "/sso/gettoken");
            OapiSsoGettokenRequest req    = new OapiSsoGettokenRequest
            {
                Corpid     = "dinga88c39dc20539c19f5bf40eda33b7ba0",
                Corpsecret = "a7KJpM71WbwteWrp8ntKcI4UArN7E4bVeoiSigHQ-HI5zJpHWhU-G9PI35tsYAOx",
            };

            req.SetHttpMethod("GET");
            OapiSsoGettokenResponse rsp = client.Execute(req);

            if (rsp.Body != null)
            {
                token = rsp.AccessToken;
                return(token);
            }
            return(token);
        }