The previous question here gave me most of the way (hopefully) for this to work, but I can't get the Google APIs working with TypeScript. I basically follow this example: https://developers.google.com/api-client-library/javascript/samples/samples
I don’t see an error, the method of starting the API call simply does not start.
I set typing for gapi and gapi.auth. initClient() does not cause any errors, it just never terminates. The current user subscribes as a Google user, but is not yet allowed to call the API. This is the next thing I was going to deal with, but now the call has not even been made. As you can see below, I added a logging line at the beginning of the method, which is not called.
initGapiClient() { gapi.load('client:auth2', this.initClient); } initClient() { gapi.client.init({ apiKey: '', discoveryDocs: ['https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest'], clientId: 'xxxxxx.apps.googleusercontent.com', scope: 'https://www.googleapis.com/auth/youtube https://www.googleapis.com/auth/youtube.readonly' }).then(function () { // Listen for sign-in state changes. gapi.auth2.getAuthInstance().isSignedIn.listen(this.updateSigninStatus); // Handle the initial sign-in state. this.updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get()); }); } updateSigninStatus(isSignedIn) { if (isSignedIn) { this.listPlaylists(); } else { alert("Can't sign in"); } } listPlaylists() { console.log("Called listPlaylists"); ... API call here ... }
source share