首页 新闻 会员 周边 捐助

微信OAuth2授权认证40029 错误 求大神解答

0
[待解决问题]

附上   代码  

这段代码 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);
                    }

有理想的人的主页 有理想的人 | 初学一级 | 园豆:5
提问于:2016-05-11 12:44
< >
分享
所有回答(1)
0

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

上帝之城 | 园豆:2549 (老鸟四级) | 2016-05-11 13:24
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册