微信OAuth2授权认证40029 错误 求大神解答
2016-05-20 来自:Becoming Jane 1 人回应

附上   代码  

这段代码 var result = OAuth2Api.GetUserId(accessToken, code, 1); 报了

if (System.Web.HttpContext.Current.Session["_wxUser"] == null)
                {
                    var code = System.Web.HttpContext.Current.Request.QueryString["code"];
                    if (!string.IsNullOrWhiteSpace(code))
                    {
                        try
                        {
                            var accessToken = AccessTokenContainer.TryGetToken(ConfigService.WeiXinCorpID, ConfigService.WeiXinSecret);
                            var result = OAuth2Api.GetUserId(accessToken, code, 1);

                            // 写日志
                            using (var db = new GWDbContext())
                            {
                                var user = db.Contacts.FirstOrDefault(u => u.UserCode == result.UserId);
                                System.Web.HttpContext.Current.Session["_wxUser"] = user;
                            }
                        }
                        catch (Exception ex)
                        {
                            // 写日志
                        }
                    }
                    else
                    {
                        // 此页面引导用户点击授权
                        var absoluteUri = HttpUtility.UrlEncode(System.Web.HttpContext.Current.Request.Url.ToString());
                        var RedirectUrl = OAuth2Api.GetCode(ConfigService.WeiXinCorpID, absoluteUri, "E2Home");

                        filterContext.Result = new RedirectResult(RedirectUrl);
                    }

2016-05-20 来自:crap

你混淆了两个概念,web和app的授权是不一样的。

您的回应

你还未登陆,不能回应!登陆