来自Chrome扩展程序的Dropbox API:拒绝加载chrome-extension:// [...]

时间:2014-01-25 13:14:43

标签: google-chrome google-chrome-extension dropbox-api

我在将Dropbox API与Chrome扩展程序集成时遇到问题。在尝试验证Dropbox时,重定向到Dropbox确认/权限页面工作正常,但重定向回Chrome应用程序失败。这是控制台中的错误:

Denying load of chrome-extension://mlabibnomhfmephibijgghejmmmbigpi/chrome_oauth_receiver.h…sGbCG&token_type=bearer&uid=14169733&state=oas_hquvrf6k_0.ycudjb24vysexw29. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.

Chrome似乎阻止Dropbox重定向回扩展程序中的页面。几个小时的权限试验没有产生任何结果。

这是manifest.json

{

  "name": "MyApp",
  "description": "Description",
  "version": "1.0",
  "icons": {"16":"icon.png",
                    "48":"icon.png",
                    "128":"icon.png"},


  "manifest_version": 2,

  "permissions": [
    "http://*/*",
    "https://*/*",
    "<all_urls>",
    "tabs",
    "storage",
    "background",
    "bookmarks",
    "clipboardRead",
    "clipboardWrite",
    "contentSettings",
    "contextMenus",
    "cookies",
    "debugger",
    "history",
    "idle",
    "management",
    "notifications",
    "pageCapture",
    "topSites",
    "webNavigation",
    "webRequest",
    "webRequestBlocking"
  ],

  "background": {
    "scripts": ["backgroundcollector.js"]
    },

    "browser_action": {
    "default_icon": "icon.png"
  },

  "web_accessible_resources": [
    "http://*/*",
    "https://*/*",
    "<all_urls>",
    "chrome-extension://mlabibnomhfmephibijgghejmmmbigpi/chrome_oauth_receiver.html&response_type=token&state=oas_hquul1r4_0.1qwu7sh12pqzolxr",
    "chrome-extension://*/*"
  ],

  "content_security_policy": "script-src 'self' https://www.dropbox.com; object-src 'self'",

  "key": "(included so that the extension gets a persistent extensionID)"

}

(大量的权限是为了让它发挥作用而进行大量实验的结果。显然它们将在以后删除。)

提前致谢!

1 个答案:

答案 0 :(得分:1)

你的清单文件中有一大堆垃圾......
要允许其他网页重定向到您的扩展程序中的网页,您必须将此文件放在"web_accessible_resources",不带chrome-extension://..前缀,如下所示:

"web_accessible_resources": [
  "chrome_oauth_receiver.html"
],

您应该请求尽可能少的权限,请参阅Declare permissions以获取每个权限的说明列表。我想你在阅读该文件后几乎可以摆脱所有许可。