0

Dies ist der Fehler, die ich bekomme, wenn die Google-signin Taste, um versuchen:Javascript Chome Erweiterung nicht geladen https://apis.google.com/js/platform.js Skript

Refused to load the script 'https://apis.google.com/js/platform.js' because it violates the following Content Security Policy directive: "script-src 'self' https://ssl.google-analytics.com". 

Dies ist Mein hTML-Header:

<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta name="google-signin-client_id" content="898781594724-s0fh16gcroad2e37ds2q09r5qmoqpu73.apps.googleusercontent.com"> 
<!-- css file --> 
<link rel="stylesheet" type="text/css" href="css/styleVidyo.css" /> 
<!-- javascript files --> 
<script type="text/javascript" src="js/vidyoChromeExt.js"></script> 
<!-- Developer code --> 
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script> 
<!-- Google analytics code --> 
<script type="text/javascript" src="js/popup.js"></script> 
<script src="https://apis.google.com/js/platform.js" async defer></script> 
<!-- Opensource code --> 
</head> 

Dies ist das Manifest:

{ 
"update_url": "https://clients2.google.com/service/update2/crx", 

"manifest_version": 3, 
"omnibox": { "keyword" : "Send a Vidyo Invite" }, 
"name": "Send a Vidyo Invite", 
"description": "Quickly send a Vidyo invite using Google Mail or Google Calendar", 
"version": "2.0.2", 
"icons": { 
"16": "img/icon_16.png" , 
"48": "img/icon_48.png" , 
"128": "img/icon_128.png" 
}, 
"content_scripts": [{ 
    "matches": ["*://mail.google.com/*", "*://accounts.google.com/*", "*://www.google.com/calendar/*", "*://calendar.google.com/*"], 
    "js": ["js/jquery-2.0.3.min.js", "js/vidyoCalendar.js", "js/dateFormat.js"], 
    "css": ["css/ui.css"], 
    "run_at": "document_end" 
    }], 
"homepage_url": "http://www.vidyo.com", 
"content_security_policy": "script-src 'self' 'unsafe-eval' https://ssl.google-analytics.com; object-src 'self'", 
"permissions": [ 
    "cookies", 
    "tabs", 
    "*://*.google.com/*", 
    "http://*/*", 
    "https://*/*", 
    "notifications", 
    "contentSettings", 
    "identity" 
], 
"web_accessible_resources": [ 
    "js/jquery-1.9.1.min.js", 
    "js/vidyoChromeExt.js",  
    "vidyoChromeExt.html", 
    "js/jquery-2.0.3.min.map", 
    "img/icon_48.png", 
    "img/icon_16.png" 
], 
"background": { 
    "scripts": ["js/eventPage.js"] 
}, 
"browser_action": { 
"default_title": "Send a Vidyo Invite", 
"default_icon": "img/icon_128.png", 
"default_popup": "vidyoChromeExt.html" 
} 
} 

PS: ich habe die content_security_policy Linie bearbeitet:

"content_security_policy": "script-src 'self' 'unsafe-eval' https://ssl.google-analytics.com https://apis.google.com/js/platform.js; object-src 'self'", 

Und jetzt bekomme ich diesen Fehler:

platform.js:7 Refused to load the script 'https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en.5Qa4K6bqWYU.O/m…sv=1/d=1/ed=1/am=AQ/rs=AGLTcCNyN716KFiep1ch6_hoUSsIDwsHUA/cb=gapi.loaded_0' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-eval' https://ssl.google-analytics.com https://apis.google.com/js/platform.js". 

PPS: Ich habe es geschafft, um es die Skripte zu machen zu laden, und gehen vorbei an der content_security_policy. aber jetzt bekomme ich diesen fehler:

cb=gapi.loaded_0:155 Uncaught gapi.auth2.ExternallyVisibleError: Invalid cookiePolicy 

Irgendwelche ideeas? Ist das eine Erweiterung? Ich fand das könnte helfen: https://github.com/google/google-api-javascript-client/issues/64 Aber so weit. nichts funktioniert

Antwort

0

Ich zitiere:

.. because it violates the following Content Security Policy directive: "script-src 'self' https://ssl.google-analytics.com"

Und von Ihrem Manifest:

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

das nicht der https://apis.google.com Ursprung entspricht, und deshalb tut genau what CSP is supposed to do: verweigern auszuführen.

auf Content Security Policy in Chrome-Erweiterungen lesen, und der CSP modifizieren, dass Herkunft, nicht einzelne Skripte (wie Google API lädt mehrere Skripte als Module, und Sie wissen nicht, die URLs im Voraus) zu ermöglichen.

+0

Ich habe schon das in meinem Manifest ... –

+0

Ich änderte meine Antwort. – Xan

+0

Überprüfen Sie jetzt, wie ich alle Skripts zulassen kann, die von apis.google.com/js/platform.js geladen werden. –