title: Loading Google API Javascript Client Library into Chrome Extension
body: <p>I've been trying to wed the google api javascript client library with a chrome extension for a while now, but it seems the chrome extension has a terrible case of cold feet. The link to the script is</p>
  
  <p><a href="https://apis.google.com/js/client.js" rel="noreferrer">https://apis.google.com/js/client.js</a></p>
  
  <p>Downloading the files is messy because the script actually loads other scripts. I've tried including it in the manifest</p>
  
  <p><strong>manifest.json (excerpt)</strong></p>
  
  <pre><code>"background": {
    "scripts": [
      "background.js",
      "https://apis.google.com/js/client.js?onload=callbackFunction"
    ]
  },
  </code></pre>
  
  <p>but then the extension doesn't load. I've also tried injecting the script into the background html</p>
  
  <p><strong>background.js (excerpt)</strong></p>
  
  <pre><code> var body = document.getElementsByTagName('body')[0];
   var script = document.createElement('script');
   script.type = 'text/javascript';
   script.src = "https://apis.google.com/js/client.js?onload=callbackFunction";
  
   body.appendChild(script);
  </code></pre>
  
  <p>but the chrome debugger gives me </p>
  
  <p><code>Refused to load the script 'https://apis.google.com/js/client.js' because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:".</code></p>
  
  <p>Any ideas, or are they fated to be kept apart?</p>
  
  <p>Edit: note that you must add "?onload=myCallbackFunction" to the script url if you want to utilize a callback function. Thanks Ilya. More info <a href="https://stackoverflow.com/questions/12874491/why-is-gapi-client-from-google-plus-api-undefined">here</a></p>