【问题标题】:Meteor: Authenticating Chrome Extension via DDPMeteor:通过 DDP 对 Chrome 扩展进行身份验证
【发布时间】:2015-02-08 06:31:12
【问题描述】:

我已经构建了一个 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 应用程序对话以验证用户身份

【问题讨论】:

    标签: javascript google-chrome-extension oauth meteor ddp


    【解决方案1】:

    这个问题有点老了,但如果有人仍在寻找解决方案。我有一个类似的问题,我可以使用以下插件解决:https://github.com/mondora/asteroid。以下是如何为 twitter oauth 执行此操作的示例: https://github.com/mondora/asteroid/issues/41#issuecomment-72334353

    【讨论】:

      猜你喜欢
      • 2013-05-19
      • 1970-01-01
      • 2019-04-01
      • 2011-11-20
      • 1970-01-01
      • 2016-09-26
      • 2017-09-18
      • 1970-01-01
      • 2017-04-07
      相关资源
      最近更新 更多