繁体   English   中英

LinkedIn Learning LTI 身份验证失败

[英]LinkedIn Learning LTI failed authentication

我正在尝试通过LTI连接集成 LinkedIn Learning Single-Sign-On,但是我总是面临以下响应: LTI_FAILED_AUTHENTICATION

领英学习 - LTI_FAILED_AUTHENTICATION

当我在Saltire测试平台上测试它时,它奇怪地工作。

参数与我从以下代码发送的内容相匹配: Saltire LTI Success authentication

尝试将oauth_noncetimestampoauth_signature的值从 Saltire 复制到我的页面,这也有效,这排除了域白名单要求的可能性。

LinkedIn 支持人员回来说生成的签名似乎有问题,但我不确定它有什么问题,因为这是由传递的参数生成的。

我的页面是否有一些我没有看到的错误设置?

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="robots" content="noindex" />
    <title>Access LinkedIn Learning</title>
    <script src="bundle.js"></script>
</head>

<body>
    <form id="id_frmConnect" name="frmConnect" enctype="application/x-www-form-urlencoded">
    </form>

    <script>
        var oauth = require('oauth-sign');
        var action = 'https://www.linkedin.com/checkpoint/enterprise/login/[accountID]?application=learning&redirect=https://www.linkedin.com/learning/me';
        var method = 'POST';
        var consumer_key = '************';
        var consumer_secret = '************';
        var timestamp = Math.round(Date.now() / 1000);

        var params = {
            lti_message_type: 'basic-lti-launch-request',
            lti_version: 'LTI-1p0',
            oauth_callback: 'about:blank',
            oauth_consumer_key: consumer_key,
            oauth_nonce: btoa(timestamp),
            oauth_signature_method: 'HMAC-SHA1',
            oauth_timestamp: timestamp,
            oauth_version: '1.0',
            user_id: 'S495696'
        };

        var signature = oauth.hmacsign(method, action, params, consumer_secret);
        params.oauth_signature = signature;

        var form = document.querySelector("#id_frmConnect");
        form.action = action;
        form.method = method;
        for (var name in params) {
            var node = document.createElement("input");
            node.type = 'hidden';
            node.name = name;
            node.value = params[name];
            form.appendChild(node);
        }
    </script>
</body>

</html>

我弄清楚了这个问题。 通过使用Saltire 测试工具,我能够在使用他们的测试 URL: https://lti.tools/saltire/tp时验证我的签名是否正确生成

你可以在这里玩一个例子: https://learningcom.github.io/ltitest/index.html

因此,在查看了 LinkedIn URL 之后,我发现生成的签名带有不必要的长 URL ,其中包含参数

删除: ?application=learning&redirect=https://www.linkedin.com/learning/me

因此,我将 URL 缩短为:

var action = 'https://www.linkedin.com/checkpoint/enterprise/login/[accountID]';

没有更多的错误!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM