我试图通过一个LTI_FAILED_AUTHENTICATION.连接来集成LinkedIn学习单点登录,但是我总是面临这样的响应:LTI
当我在萨莱尔测试平台上测试它时,它奇怪地起了作用。
参数与我从下面代码中发送的内容相匹配:Saltire成功认证
已经尝试过将oauth_nonce、timestamp和oauth_signature的值从我的页面复制到我的页面,这也奏效了,这就排除了域白名单要求的可能性。
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>发布于 2021-12-23 01:51:17
我解决了这个问题。通过使用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]';
别再犯错误了!
https://stackoverflow.com/questions/70439066
复制相似问题