Google+ integration chrome extension issue

送分小仙女□ 提交于 2021-01-27 13:54:25

问题


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

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

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

Refused to execute JavaScript URL because it violates the following Content Security Policy directive: "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".

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

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.

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.

Do you have any experience with that ?


回答1:


Try this in your manifest.json:

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


来源:https://stackoverflow.com/questions/18194659/google-integration-chrome-extension-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!