chrome extension and dropbox dropin saver error

大城市里の小女人 提交于 2019-12-13 00:15:02

问题


I'm writing a chrome extension to save images found on a webpage to dropbox. I'm trying to use the dropin saver api to do this, however I am getting an error when the "save to dropbox" link is being clicked.

The error I receive is as follows:

{"error": "Origin does not match any app domain"}

An examination of the GET request reveals the following:

GET https://www.dropbox.com/saver?origin=chrome-extension%3A%2F%2Fogmklfknlcgklhfljkcijikghbnghcal&app_key=MYDROPBOXKEY 403 (OK)

The error and the 403 lead me to believe that there was an issue with declaring permissions in my chrome extension manifest file. However, I've tried what I believe should work as per the documentation, and I get the same result. My manifest file is as follows:

{
  "name": "Pic Grabber",
  "version": "1.0",
  "permissions": [
    "activeTab",
    "tabs", "<all_urls>", "background", "http://*/", "https://*/", "http://*/*", "https://*/*", "https://www.dropbox.com/*"
  ],
  "content_scripts": [{
        "js": ["grabber.js"],
        "matches": ["http://*/", "https://*/", "http://*/*", "https://*/*", "https://www.dropbox.com/*"]
    }],
  "background": {
    "scripts": ["background.js"],
    "persistent": false
  },
  "browser_action": {
    "default_title": "Download pictures from this page.",
    "default_icon": "icon.png",
    "default_popup": "popup.html"
  },
  "manifest_version": 2,
  "content_security_policy": "script-src 'self' https://www.dropbox.com/static/api/1/dropins.js; object-src 'self'"
}

I imagine that I'm missing something obvious, but cannot seem to put my finger on it. It seems like my manifest specifies all the necessary cross-origin permissions. Any nudges in the right direction would be greatly appreciated.

Thanks!


回答1:


The Dropbox Saver Dropin checks the domain which the button is being displayed/used on against a list of domains specified when you registered the app.

Since this is a chrome extension, it does not have the usual type of domain name, so instead you need to add the chrome extension ID in the Drop-ins domains in the Dropbox App Console.

Your extension ID is ogmklfknlcgklhfljkcijikghbnghcal (visible in the origin value of the dropbox URL you posted). If you add this to the drop in domains then it should work fine.




回答2:


I think this error is coming from Dropbox and means that the page that's originating the call to the Dropbox Saver is not on a domain you allowed via the App Console.

If the Saver is originating on a page that's part of your extension, you should be able to just add that domain (the ugly string after chrome-extension://) in the App Console and be good to go.



来源:https://stackoverflow.com/questions/19674172/chrome-extension-and-dropbox-dropin-saver-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!