"gapi is not defined" exception when calling gapi.auth.authorize

3,417 views
Skip to first unread message

Julia Razmyslovich

unread,
May 20, 2016, 2:12:24 PM5/20/16
to Chromium-extensions
Hi All,

I'm trying to add chrome extension that should use GAPI.

Manifest file:
{
  "name": "EXTENSION NAME",
  "description": "EXTENSION DESCRIPTION",
  "version": "0.1",
  "manifest_version": 2,
  "content_scripts": [{
    "js": ["content.js"],
    "matches": ["https://*.something.com/*"]
  }],
  "content_security_policy": "script-src 'self' https://apis.google.com; object-src 'self'"
}

content.js:

var script = document.createElement("script");
script.type = 'text/javascript';
document.head.appendChild(script);

Have "gapi is not defined" exception when calling gapi.auth.authorize

Could you help please?

Thank you,
Julia

Mykyta Khmel

unread,
May 21, 2016, 7:21:44 PM5/21/16
to Chromium-Extensions-Announce
  1. gapi should be in scope of function handleClientLoad 
  2. you should call gapi.load for load particular API

Pnj Patel

unread,
Jul 28, 2020, 1:15:04 AM7/28/20
to Chromium Extensions, hmel...@gmail.com
you need to add this cdn..
  <script src="https://apis.google.com/js/api.js" async defer></script>

PhistucK

unread,
Jul 28, 2020, 5:04:51 AM7/28/20
to Pnj Patel, Chromium Extensions, hmel...@gmail.com
I am not sure running remote code is allowed in Chrome extensions anymore, though.

PhistucK


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/ed2af418-8b2d-433d-8b9d-98e267163de3n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages