components/gcp-click-to-deploy/src/App.js
// 3. Creates a client for the deployment manager.
3. Creates a client for the deployment manager.
3 . Creates a client for the deployment manager .
createClients() {  
    console.log("createClients called");
    window.gapi.load('auth2', 
      function () {});
    var thisVar = this;
    gapi.load('signin2', function(){
      console.log("Loaded signin2");
    });
    gapi.load('client:auth2', function() {    
      gapi.client.load('deploymentmanager','v2').then(function() {
      console.log("Loaded deploymentmanager");
      thisVar.state.clientLoaded = true;
      console.log("load auth2");
      gapi.auth2.init({fetch_basic_profile: false,
          client_id: clientId,
          scope:'https://www.googleapis.com/auth/cloud-platform'}).then(
            function (){
              console.log('init');
              auth2 = gapi.auth2.getAuthInstance();              
              auth2.isSignedIn.listen(updateSignIn);
              auth2.then(updateSignIn);
            });
      console.log("render button");      
      gapi.signin2.render('loginButton', {
          width: 200,
          height: 50,
          scope: 'https://www.googleapis.com/auth/cloud-platform',
          fetch_basic_profile: false })
      }).catch(function(error){
        console.log("Error occured loading deployment manager: " + error);
      });
    });
  } 
createClients ( ) { console . log ( "createClients called" ) ; window . gapi . load ( 'auth2' , function ( ) { } ) ; var thisVar = this ; gapi . load ( 'signin2' , function ( ) { console . log ( "Loaded signin2" ) ; } ) ; gapi . load ( 'client:auth2' , function ( ) { gapi . client . load ( 'deploymentmanager' , 'v2' ) . then ( function ( ) { console . log ( "Loaded deploymentmanager" ) ; thisVar . state . clientLoaded = true ; console . log ( "load auth2" ) ; gapi . auth2 . init ( { fetch_basic_profile : false , client_id : clientId , scope : 'https://www.googleapis.com/auth/cloud-platform' } ) . then ( function ( ) { console . log ( 'init' ) ; auth2 = gapi . auth2 . getAuthInstance ( ) ; auth2 . isSignedIn . listen ( updateSignIn ) ; auth2 . then ( updateSignIn ) ; } ) ; console . log ( "render button" ) ; gapi . signin2 . render ( 'loginButton' , { width : 200 , height : 50 , scope : 'https://www.googleapis.com/auth/cloud-platform' , fetch_basic_profile : false } ) } ) . catch ( function ( error ) { console . log ( "Error occured loading deployment manager: " + error ) ; } ) ; } ) ; }
3.
3 .
// Initialize the API client library //   //On load, called to load the auth2 library and API client library. // TODO(jlewi): Why do we load the client for deployment manager // when load of auth2 is done? // If we don't set a var = to this then we can't bind this in the // callback. // See: https://developers.google.com/identity/sign-in/web/reference // Initializes the auth2 library. //onSucess: updateSignIn, // startApp