ngGAPI icon indicating copy to clipboard operation
ngGAPI copied to clipboard

Unable to call init() on GAPI

Open alistaircolling opened this issue 8 years ago • 2 comments

Hi, I can't seem to initialize GAPI and I'm not sure why. I get this error message:

TypeError: Cannot read property 'authorize' of undefined at Function.GAPI.init (gapi.js:404) at new (main.min.js:303) at invoke (angular.js:3720) at Object.instantiate (angular.js:3731) at angular.js:6848 at q (angular-ui-router.min.js:7) at A (angular-ui-router.min.js:7) at Scope.$broadcast (angular.js:12329) at t.transition.N.then.t.transition.t.transition (angular-ui-router.min.js:7) at wrappedCallback (angular.js:11033)

Here's the code from my controller: routerApp.controller('home-controller', function($scope, GAPI, Calendar) { //debugger; GAPI.init(); var cal = Calendar.getCalendars('[email protected]');

I'm not sure if this is a bug or if I'm missing something obvious 😳.

Thanks! Alistair

alistaircolling avatar Aug 04 '16 15:08 alistaircolling

Same here.

salarelv avatar Jan 02 '17 09:01 salarelv

I don't know exactly why this is happening, but the client id is not recognised by the library so you have to add the client id on google client library load

This works for me: <script src="https://apis.google.com/js/client.js?onload=onClientLoad"></script>

and then in the function: function onClientLoad(){ gapi.client.load('calendar', 'v3', function(){ gapi.client.setApiKey('YOUR_CLIENT_ID_HERE }); }

Hope this helps.

Spatlani avatar Jan 09 '17 19:01 Spatlani