Senparc.Weixin.Work.AdvancedAPIs.OAuth2Api.GetCode C# (CSharp) Method

GetCode() public static method

企业获取code
public static GetCode ( string corpId, string redirectUrl, string state, string responseType = "code", string scope = "snsapi_base" ) : string
corpId string 企业的CorpID
redirectUrl string 授权后重定向的回调链接地址,请使用urlencode对链接进行处理
state string 重定向后会带上state参数,企业可以填写a-zA-Z0-9的参数值
responseType string 返回类型,此时固定为:code
scope string 应用授权作用域,此时固定为:snsapi_base
return string
        public static string GetCode(string corpId, string redirectUrl, string state, string responseType = "code", string scope = "snsapi_base")
        {
            var url = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type={2}&scope={3}&state={4}#wechat_redirect", corpId.AsUrlData(), redirectUrl.AsUrlData(), responseType.AsUrlData(), scope.AsUrlData(), state.AsUrlData());

            return url;
        }