Undefined function gapi.client.setApiKey in Safari

317 views
Skip to first unread message

Igor Cherepanov

unread,
Apr 13, 2015, 1:51:15 PM4/13/15
to google-api-jav...@googlegroups.com
Hello! I'm trying to use the sample code from AuthSample in the Safari extension
I've got this function along with other code from the sample, and the part that loads the library.
 function handleClientLoad() {
          safari.extension.globalPage.contentWindow.console.log(gapi);
        gapi.client.setApiKey(apiKey);
        checkAuth();
      }

This is what i get once the lib is loaded - and there's no client or auth in the gapi object. 

[Log] Object (popover.html, line 29)
_: Object
config: Object
load: function (a, b) {return ua(function(){return xa(a,b)});}
loaded_0: function (a) {w[x](a);I[R]=null;}
loaded_1: null
__proto__: Object

Cause of that I get an error about undefined functions. handleClientLoad never called manually, so i guess it means that it's loaded.

Am i missing something? Or is this never going to work in Safari extension?
Thank you

Einav C

unread,
Apr 27, 2015, 6:50:27 AM4/27/15
to google-api-jav...@googlegroups.com
Same for us on chrome, 
GET https://apis.google.com/_/scs/apps-static/_/js/k=oz.gapi.en.j1QholfdnmY.O/m…1/ed=1/am=AQ/rs=AGLTcCP1BSvtxoI3E2wzG7twjHbDrCUuHA/t=zcms/cb=gapi.loaded_0  
returns 404 and the gapi.client is undefined. this is something that used to work for us and stopped working lately.

Igor Cherepanov

unread,
May 4, 2015, 11:42:58 AM5/4/15
to google-api-jav...@googlegroups.com
i did some digging and here's what i've found 
Upon loading client.js there's some function that checks self.window.location.href
    if ("http" !== a && "https" !== a && "chrome-extension" !== a && "file" !== a)
        throw Error("Pa");
and in my case it's safari-extension so it throws an error
it should work for the chrome though

Petre Angelovski

unread,
Jan 4, 2016, 1:23:07 PM1/4/16
to Google API JavaScript Client
Did anyone solve this?

Igor Cherepanov

unread,
Jan 4, 2016, 4:28:29 PM1/4/16
to Google API JavaScript Client
We poked around and found somewhere a hardcoded condition that allows it to work only in Chrome
Also apple made Safari extensions development paid as well, so i stopped working on that for now
Reply all
Reply to author
Forward
0 new messages