我已经构建了一个Chrome扩展,它接受选择的文本,当我右键单击并选择上下文菜单项时,它会将文本发送到我的Meteor应用程序。这很好用,但是我不知道使用Oauth对用户进行身份验证的过程。
我正在使用这个包:https://github.com/eddflrs/meteor-ddp
下面是background.js中的JS (用于Chrome扩展):
var ddp = new MeteorDdp("ws://localhost:3000/websocket");
ddp.connect().then(function() {
ddp.subscribe("textSnippets");
chrome.runtime.onMessage.addListener(function(message) {
ddp.call('transferSnippet', ['snippetContent', 'tag', snippetString]);
});
});下面是我的Chrome扩展中其他JS文件的相关部分:
function genericOnClick(info) {
snippetString = [];
snippetString.push(info.selectionText);
var snippetTag = prompt('tag this thing')
snippetString.push(snippetTag);
chrome.runtime.sendMessage(snippetString);
}这是我的Meteor应用程序的相关部分:
'transferSnippet': function(field1, field2, value1, value2) {
var quickObject = {};
quickObject.field1 = value1[0];
quickObject.field2 = value1[1];
TextSnippets.insert({
snippetContent: value1[0],
tag: value1[1]
});
}基本上,我被卡住了,不知道如何进行DDP呼叫,以便与我的Meteor应用程序对话,以便对用户进行身份验证
发布于 2015-05-07 01:08:31
这个问题有点老了,但如果有人还在寻找解决方案的话。我有一个类似的问题,我可以使用以下插件解决:https://github.com/mondora/asteroid。这里有一个如何在twitter oauth中做到这一点的例子:https://github.com/mondora/asteroid/issues/41#issuecomment-72334353
https://stackoverflow.com/questions/27394640
复制相似问题