Loading google client.js

For developers using the Construct 2 Javascript SDK

Post » Wed Feb 05, 2014 2:25 pm

I'm a bit of a javascript beginner and am finding it a problem to get google api authorization (oauth2) under node-webkit. There may well be fundamental problems with doing this that I'm just not aware of.

I borrowed abit of code from @thehen and flurry, as you see below. On running, a popup appears saying 'setApiKey' is undefined. Looking in the client.js library (which is minified), I can't see any 'setApiKey' method. Maybe client.js loads another external library? (I've got no idea really and hope someone can point me in the right direction.) Thanks.

var s = document.createElement("script");
          s.src = "https://apis.google.com/js/client.js";
          s.async = true;
          document.getElementsByTagName("head")[0].appendChild(s);
          s.onload = function() {
    gapi.client.setApiKey('AIzaSyCtG9M0qrfx...SE6bcDRKAQoX5u5do');
               self.gapi_ready = true;
          }
B
12
S
3
G
4
Posts: 57
Reputation: 3,186

Post » Thu Feb 06, 2014 11:50 am

Ok, I have it authenticating in node-webkit. I used 'google-api-nodejs-client'.

@Ashley, currently I place the 'node_modules' in my home directory because I couldn't get it working any other way. I read Roger Wangs article at https://github.com/rogerwang/node-webkit/wiki/Using-Node-modules, but still can't work out how to run node-webkit with modules, where they are not global (i.e. in my home dir). Thanks.
B
12
S
3
G
4
Posts: 57
Reputation: 3,186

Post » Thu Feb 06, 2014 1:37 pm

I can't really help you here, it's not really anything specific to the Javascript SDK. A site like stackoverflow.com might be able to help better.
Scirra Founder
B
395
S
232
G
88
Posts: 24,368
Reputation: 193,756


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests