Search code examples
javascriptgoogle-chromegoogle-chrome-extensiondropbox

chrome extension and dropbox dropin saver error


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!


Solution

  • 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.