流星:通过DDP验证Chrome扩展程序
Meteor: Authenticating Chrome Extension via DDP
我构建了一个Chrome扩展程序,它接受选择的文本,当我右键单击并选择上下文菜单项时,它会将该文本发送到我的Meteor应用程序。这工作正常,但是,我无法弄清楚使用 Oauth 对用户进行身份验证的过程。
我正在使用这个包:https://github.com/eddflrs/meteor-ddp
以下是后台的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);
}
这是我的流星应用程序的相关部分:
'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应用程序通信以对用户进行身份验证
这个问题有点老了,但如果有人还在寻找解决方案。我有一个类似的问题,我能够使用以下插件解决:https://github.com/mondora/asteroid。以下是如何为 Twitter oauth 执行此操作的示例:https://github.com/mondora/asteroid/issues/41#issuecomment-72334353
相关文章:
- chrome扩展中的navigator.geolocation.getCurrentPosition
- chrome扩展:尽管运行了at:documentidle,js脚本还是过早启动
- chrome扩展更改主机/域警告
- 如何在chrome扩展中重定向到html页面
- Chrome扩展没有't在重新加载之前考虑期权价值
- 如何通过自己获得Chrome扩展的用户反馈/错误报告
- 如何在chrome扩展中存储数据/结果,以及如何使用setTimeout使其只被调用一次
- 从选项页面更新chrome扩展清单权限
- 如何将chrome扩展功能移植到移动设备(特别是jquery和trello)
- Chrome扩展:遍历不同的页面并收集数据
- 未捕获的类型错误:无法读取属性'addEventListener'的null chrome扩展名
- 可以从Chrome扩展修改窗口对象吗
- 从popup.js|Chrome扩展访问DOM
- 从Chrome扩展名中的popup.html文件在background.js文件中运行一个函数
- 在Chrome扩展内部输出Google API调用
- 检查是否存在使用chrome扩展的javascript库
- 从Chrome扩展访问Google Cloud SQL数据库
- Chrome扩展,Chrome.tabs.query的结果未定义
- 为tweet构建chrome扩展
- 在chrome扩展中使用AJAX获取目录中的文件数