简体   繁体   English

谷歌日历 API 与 Chrome 扩展

[英]Google Calendar API with Chrome Extension

I am trying to build a Chrome Extension that will interact with the Google Calendar API in order to add events to my calendar.我正在尝试构建一个 Chrome 扩展程序,它将与 Google 日历 API 交互,以便将事件添加到我的日历中。 I am more or less following the directions here but the problem is that Chrome's Content Security Policies are blocking the script tags.我或多或少遵循这里的指示,但问题是 Chrome 的内容安全策略正在阻止脚本标签。 To try to solve this, I downloaded https://apis.google.com/js/api.js and imported it with <script src="api.js"></script> .为了解决这个问题,我下载了 https://apis.google.com/js/api.js并使用<script src="api.js"></script>导入它。 However, now I get the error:但是,现在我得到了错误:

"Refused to load the script 'https://apis.google.com/ /scs/apps-static/ /js/k=oz.gapi.en.-F_i8pxym_s.O/m=auth2,client/rt=j/sv=1/d=1/ed=1/am=AQ/rs=AGLTcCOcSmYYH6pFUBh5t_7PICWuDXqniQ/cb=gapi.loaded_0' because it violates the following Content Security Policy directive: "script-src 'self'". Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback." "拒绝加载脚本' https://apis.google.com//scs/apps-static//js/k=oz.gapi.en.-F_i8pxym_s.O/m=auth2,client/rt=j/ sv=1/d=1/ed=1/am=AQ/rs=AGLTcCOcSmYYH6pFUBh5t_7PICWuDXqniQ/cb=gapi.loaded_0' 因为它违反了以下内容安全策略指令:“script-src 'self'”。请注意,'script- src-elem' 没有明确设置,所以 'script-src' 被用作后备。”

It seems that the script I imported tries to download another script online.我导入的脚本似乎试图在线下载另一个脚本。 Should I download that one too?我也应该下载那个吗? If not, how should I proceed?如果没有,我应该如何进行? Also, given the nature of the Chrome Extension, will other parts of the example I linked above fail?另外,鉴于 Chrome 扩展程序的性质,我上面链接的示例的其他部分会失败吗?

Thanks for your help!谢谢你的帮助!

Based on this "Note that 'script-src-elem' was not explicitly set, so 'script-src' is used as a fallback.", I think it's stating the solution here, you should set基于这个“注意'script-src-elem'没有明确设置,所以'script-src'被用作后备。”,我认为它在这里说明了解决方案,你应该设置

script-src-elem

along with the随着

script-src

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM