Accessing Google Sheets from Chrome extension via Chrome Identity API
<p>I'm trying to read data from a Google Sheet via a Chrome extension leveraging Chrome Identity API, but I'm not even able to get an access token. This is what I've done so far:</p>

<ul>
<li>Created an OAuth 2 client ID in Google API Console. Entered "<a href="http://localhost" rel="nofollow">http://localhost</a>" and "<a href="https://localhost" rel="nofollow">https://localhost</a>" in the authorized JavaScript origins (since my extension is in localhost for now). </li>
<li>Updated the Chrome extension's <code>manifest.json</code> to include:</li>
</ul>

<pre><code>{
  "permissions": [
    "identity",
    "https://docs.google.com/spreadsheets/"
  ],
  "oauth2": {
    "client_id": "&lt;enter-oauth2-client-id-here&gt;",
    "scopes": [
      "https://docs.google.com/spreadsheets"   
    ]
  }
}
</code></pre>

<ul>
<li>Added the following code in a background script</li>
</ul>

<pre><code>console.log("here"); // this point is hit

var ci = chrome.identity;
ci.getAuthToken({ interactive: true }, function(token) {
    console.log("token: " + token); // none of this is hit
    if (chrome.runtime.lastError) {
        console.log(chrome.runtime.lastError);
        return;
    }
    access_token = token;
});
</code></pre>

<p>At this point, when I reload the extension, Chrome asks me for my credentials (the <code>ci.getAuthToken({ interactive: true } ...)</code> line is executed), but once the credentials are successfully provided, nothing else happens. I guess the token is never retrieved, which is why none of the code within <code>function(token){...}</code> is executed. The background console shows the "here" message, but nothing else (no errors, warnings, or anything).</p>

<p>Note: In my <code>manifest.json</code>, under <code>oauth2:client_id</code> I'm using the OAuth2 client Id generated by the Google API Console.</p>

<p>What am I missing? </p>