【问题标题】:Google+ integration chrome extension issueGoogle+ 集成 chrome 扩展问题
【发布时间】:2013-08-12 19:01:12
【问题描述】:

我正在尝试将 google+ API 与我的 google chrome 扩展程序集成。我的集成基于此处介绍的此快速入门示例: https://developers.google.com/+/quickstart/javascript

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

"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.comhttps://csi.gstatic.comhttps://developers.google.com;object-src'self'"

问题如下。当我点击 Google+ 按钮时,我收到以下错误消息:

拒绝执行 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 行抛出此异常:

https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en.aop9WHMC8-8.O/m=client,plusone,signin/rt=j/sv=1/d=1/ed=1/am=EQ/rs=AItRSTNUM79OpqDtwYl6kryPkOs00evROQ/cb=gapi.loaded_0.

它似乎试图嵌入内联脚本并在之后执行它,这违反了内容安全策略。 当我单击弹出窗口中的“接受”按钮时,会出现相同的异常。结果弹出窗口挂起而没有响应。

你有这方面的经验吗?

【问题讨论】:

标签: google-chrome-extension google-plus content-security-policy


【解决方案1】:

在您的 manifest.json 中试试这个:

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

【讨论】:

    猜你喜欢
    • 2023-03-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-09
    • 2018-11-24
    相关资源
    最近更新 更多