开发者社区> 问答> 正文

钉钉微应用OAuth2授权打开一个应用时提示对不起您无权限查看该页面

钉钉微应用OAuth2授权打开一个应用时提示对不起您无权限查看该页面,但是打开同企业其他应用没有问题,同企业其他人打开该应用没有问题,问下可能的原因是什么?

//简化代码如下:
public ActionResult Index()
        {
            string q="/Mobile/Mobile/Index";
            string appId = Request["appid"];
            if (string.IsNullOrEmpty(appId))
            {
                //判断是否存在code
                string code = Request["code"];
                if (!string.IsNullOrEmpty(code))
                {
                    #region 钉钉oauth登陆
                    string appid = Session["AppId"].ToString();
                    string agentid = Session["AgentId"].ToString();
                    //此处调用接口获取部门信息
                    string corpid = Session["CorpId"].ToString();
                    string corpSecret = Session["CorpSecret"].ToString();
                    var tokenModel = EnterpriseBusiness.GetToken(corpid, corpSecret);
                    var access_token = tokenModel.access_token;

                    //---------------利用access_token和code去换取当前用户
                    var userModel = EnterpriseBusiness.GetCurrentUser(access_token, code);

                    //登录
                    if (userModel != null)
                    {
                        string dingtalkAccount = userModel.userid;
                        int lefttimes = 0;
                        Clusterware.ConnectionResult result = UserContextFactory.Login(HttpContext,
                            H3.Clusterware.AccountType.DingTalkAccount,
                            "",
                            dingtalkAccount,
                            "",
                            out lefttimes);
                        if (result != Clusterware.ConnectionResult.Success)
                        {
                            return Redirect(MobileLoginPath + "?q=" + q);
                        }
                        else
                        {
                            return View();
                        }
                    }
                    else
                    {
                        return Redirect(MobileLoginPath + "?q=" + q);
                    }
                    #endregion
                }
                else
                {
                    //判断pc端登陆
                    if (this.UserContext != null)
                    {
                        return View();
                    }
                    else
                    {
                        return Redirect(MobileLoginPath + "?q=" + q);
                    }
                }
            }
            else
            {
                string corpId = Request["corpid"];
                string corpSecret = Request["corpsecret"];
                string agentId = Request["agentid"];

                Session["CorpId"] = corpId;
                Session["AppId"] = appId;
                Session["CorpSecret"] = corpSecret;
                Session["AgentId"] = agentId;

                //判断是否存在cookie
                if (Request.Cookies[corpId] != null && Request.Cookies[corpId].Value != "")
                {
                    //登录并直接跳转
                    string userId = H3.Security.DESEncryptor.DecryptDES(
                            Request.Cookies[corpId].Value,
                            UserContextFactory.Cookie_encrytkey);
                    int lefttimes = 0;
                    Clusterware.ConnectionResult result = UserContextFactory.Login(HttpContext,
                        H3.Clusterware.AccountType.DingTalkAccount,
                        "",
                        userId,
                        "",
                        out lefttimes);
                    if (result == Clusterware.ConnectionResult.Success)
                    {
                        return View();
                    }
                }
                string callback = Request.Url.ToString().Split('?')[0];
                string authUrl = string.Format("https://oapi.dingtalk.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=SCOPE&state=State", corpId, callback);
                return Redirect(authUrl);
            }          
        }

展开
收起
eys 2015-12-18 12:06:59 14526 0
2 条回答
写回答
取消 提交回答
  • eys
    回 1楼君信的帖子
    企业内的多个应用,只有一个应用存在这个问题;
    无权查看微应用是值什么呢 ,现在配置的应用是所有人都可见的;

    -------------------------

    回 3楼君信的帖子
    确实是缓存的问题,但是app清理缓存没用,还是通过停用应用后再启用解决的!
    2015-12-18 14:28:39
    赞同 展开评论 打赏
  • 这个问题的原因一般是因为您不属于这个企业,或者你无权查看这个微应用。

    -------------------------

    回 2楼(eys) 的帖子
    目前应该是缓存的问题
    2015-12-18 14:08:44
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
钉钉小程序——为工作方式插上翅膀 立即下载
钉钉客户端自动化的应用 立即下载
使命必达 —— 钉钉企业级 消息服务的机遇与挑战 立即下载