Chrome扩展和Dropbox Dropin保存错误 [英] chrome extension and dropbox dropin saver error

查看:121
本文介绍了Chrome扩展和Dropbox Dropin保存错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Chrome扩展程序,将网页上找到的图像保存到Dropbox。我正在尝试使用保护程序api 执行此操作,但是我得到了一个点击save to dropbox链接时出错。



我收到的错误如下:


{error:Origin与任何应用程序域不匹配}

GET请求揭示了以下内容:

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

错误和403让我相信在我的Chrome扩展清单文件中声明权限时出现问题。不过,我已经尝试了我认为应该按照文档工作,我得到相同的结果。我的清单文件如下:

  {
name:Pic Grabber,
版本:1.0,
权限:[
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/*]
}],
后台:{
scripts:[background.js],
persistent:false
},
browser_action:{
default_title :从此页下载图片,
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'
}

我想象我错过了显而易见的东西,但似乎无法把它放在手指上。似乎我的清单指定了所有必需的跨源许可。任何向正确方向的推动都将不胜感激。



谢谢!

解决方案

Dropbox Saver Dropin会在您注册应用程序时指定的域名列表中检查显示/使用该按钮的域名。



由于这是Chrome扩展程序,它没有常用的域名类型,因此您需要在Dropbox App Console的Drop-ins域中添加Chrome扩展标识。

您的扩展程序ID为ogmklfknlcgklhfljkcijikghbnghcal(可在您发布的保管箱URL的原始值中显示)。如果您将此添加到域中的删除,那么它应该很好。


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!

解决方案

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.

这篇关于Chrome扩展和Dropbox Dropin保存错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆