我正在尝试在我的网站上集成Disqus SSO。
var DISQUS_SECRET = "xyz";
var DISQUS_PUBLIC = "abc";
var disqus_developer = 1;
function disqusSignon() {
var disqusData = {
id: "{{ user.id }}",
username: "{{ user.username }}",
email: "{{ user.email }}"
};
var disqusStr = JSON.stringify(disqusData);
var timestamp = Math.round(+new Date() / 1000);
var message = window.btoa(disqusStr);
var result = CryptoJS.HmacSHA1(message + " " + timestamp, DISQUS_SECRET);
var hexsig = CryptoJS.enc.Hex.stringify(result);
return {
pubKey: DISQUS_PUBLIC,
auth: message + " " + hexsig + " " + timestamp
};
}
var data = disqusSignon();
function disqus_config(){
this.callbacks.afterRender = [function() {
this.page.remote_auth_s3 = data.auth;
this.page.api_key = data.pubKey;
}];
}
var disqus_config = function() {
this.page.remote_auth_s3 = data.auth;
this.page.api_key = data.pubKey;
}
var disqus_shortname = 'askpopulo';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
一切都很好,生成的有效载荷在Disqus SSO调试工具上也得到了正确验证。但是用户仍然无法使用SSO登录。
此外,还会在JavaScript控制台中打印出以下消息:
看起来出现了问题:错误:数据不足{stack: (...), message: "Not enough data"}信息:"数据不足"堆栈:(...)获取堆栈:function () { [native code] }参数:null调用者:null长度:0名称:""原型:StackTraceGetter__proto__:function Empty() {}设置堆栈:function () { [native code] }参数:null调用者:null长度:1名称:""原型:StackTraceSetter__proto__:function Empty() {}proto:dr.DiscoveryApp.a.Model.extend.onComplete @ discovery.bundle.fce1a5edaced8a1898cef54c2d9fb2bf.js:2(匿名函数) @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9(匿名函数) @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9p @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9o @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9e @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9(匿名函数) @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9(匿名函数) @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9p @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9o @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9c @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9(匿名函数) @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9(匿名函数) @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9p @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9o @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9c @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9(匿名函数) @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9(匿名函数) @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.js:9p @ common.bundle.91cd39decece4de79b12c1d2e99a09c8.j