开发者社区> 问答> 正文

钉钉免登陆报错

报错内容:


权限校检失败
code:52011;
Message:jsapi ticket 读取失败
errorCode:3


下面为我的前端代码:
=====================================================================================================================

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript"  src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
    <script type="text/javascript" src="https://g.alicdn.com/ilw/ding/0.9.2/scripts/dingtalk.js"></script>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        #userName{
            width: 100%;
            height: 50px;
            border: 1px solid red;
        }
        #userId{
            width: 100%;
            height: 50px;
            border: 1px solid red;
        }
        #btn{
            width: 100%;
            height: 100px;
        }
    </style>
</head>
<body>


<button type="button" id="btn">请求数据</button>
<div id="userName"></div>
<div id="userId"></div>
<script>
    $("#btn").on("click", function () {
        $.getJSON("http://******.com/initcs/ding", function (datas) {
            alert(datas.signature)
            dd.config({                                                //dd.config方法会对参
                agentId : datas.agentId,
                corpId : datas.corpId,
                timeStamp : datas.timeStamp,
                nonceStr : datas.nonceStr,
                signature : datas.signature,
                type:0,
                jsApiList : [                              //需要调用的借口列表
                    'runtime.info',
                    'device.notification.prompt',
                    'biz.chat.pickConversation',
                    'device.notification.confirm',
                    'device.notification.alert',
                    'device.notification.prompt',
                    'biz.chat.open',
                    'biz.util.open',
                    'biz.user.get',
                    'biz.contact.choose',
                    'biz.telephone.call',
                    'biz.ding.post' ]
            });
            dd.ready(function () {                                               //验证成功
                dd.runtime.info({
                    onSuccess : function(info) {
                        logger.e('runtime info: ' + JSON.stringify(info));
                    },
                    onFail : function(err) {
                        logger.e('fail: ' + JSON.stringify(err));
                    }
                });
                dd.runtime.permission.requestAuthCode({                         //获取code
                    corpId:datas.corpId,
                    onSuccess: function (info) {
                        alert('authcode: ' + info.code);
                        $.ajax({
                            url: 'userinfo?code=' + info.code + '&corpid='     //请求后台通过code值获得userId
                            + datas.corpId,
                            type: 'GET',
                            success: function (data, status, xhr) {
                                var info = JSON.parse(data);
                                document.getElementById("userName").innerHTML = info.name;
                                document.getElementById("userId").innerHTML = info.userid;
                            },
                            error: function (xhr, errorType, error) {
                                logger.e("yinyien:" + datas.corpId);
                                alert(errorType + ', ' + error);
                            }
                        });
                    },
                    onFail: function (err) {
                        alert('fail: ' + JSON.stringify(err));
                    }
                });
            });
            dd.error(function (err) {                                             //验证失败
                alert("进入到error中");
                document.getElementById("userName").innerHTML = "验证出错";
                alert('dd error: ' + JSON.stringify(err));
            });


        })
    });




</script>
</body>
</html>
===============================================================================================
求各位帮忙解决一下 拜谢

展开
收起
星宇寒风 2017-04-26 16:55:03 3045 0
0 条回答
写回答
取消 提交回答
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

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