Google+集成Chrome扩展程序问题 [英] Google+ integration chrome extension issue

查看:66
本文介绍了Google+集成Chrome扩展程序问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将google + API与我的google chrome扩展集成.我基于此快速入门示例进行了集成: https://developers.google.com/+/quickstart/javascript

I am trying to integrate google+ API with my google chrome extension. My integration based on this quick start example introduced here: https://developers.google.com/+/quickstart/javascript

我已将所有内联javascript代码迁移到单独的文件,并在manifest.json文件中添加了content_security_policy行:

I have migrated all inline javascript code to separate files, added content_security_policy line in my manifest.json file:

"content_security_policy":"script-src'self' https://www.googleapis.com/ https://plus.google.com/ https://帐户.google.com/ https://ssl.gstatic.com https://developers.google.com ; object-src'self'"

"content_security_policy": "script-src 'self' https://www.googleapis.com/ https://plus.google.com/ https://apis.google.com/ https://accounts.google.com/ https://ssl.gstatic.com https://csi.gstatic.com https://developers.google.com; object-src 'self'"

以下是问题.当我点击Google+按钮时,出现以下错误消息:

The problem is following. When I click on the Google+ button I get following error message:

拒绝执行JavaScript URL,因为它违反了以下内容安全政策指令:"script-src'self'https://www.googleapis.com/https://plus.google.com/https://apis.google.com/https://accounts.google.com/https://ssl.gstatic.com https://csi.gstatic.com https://developers.google.com"

显然对content_security_policy不满意.它将在此文件的第468行引发此异常:

Which is obviously unhappy with content_security_policy. It throws this exception on line 468 in this file:

似乎正在尝试嵌入内嵌脚本并在之后执行它,这违反了内容安全策略.当我单击弹出窗口中的接受"按钮时,也会出现相同的例外.结果,弹出窗口挂起而没有响应.

It seems it is trying to embed inline script and execute it after, which violates Content Security Policy. The same exception appears when I click to "Accept" button in the popup. As a result popup window hangs without response.

您对此有任何经验吗?

推荐答案

在您的 manifest.json 中尝试一下:

"content_security_policy": "script-src 'self' 'unsafe-eval' https://apis.google.com/; object-src 'self'"

这篇关于Google+集成Chrome扩展程序问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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