How to use google login button in angular.js 2.0 typescript application?

I am trying to enable the Google login button in SPA Angular.js 2.0 (typescript), but I don’t know what is the right way to implement Google callback in such a way that something works my Angular.

(or, alternatively, I wonder if it is correct to write a directive, but then how do I make a callback?)

Edit: adding source code

  ngAfterViewInit() {
    gapi.signin2.render(
      "google-login-button",
      {
        "onSuccess": (user) => console.log(user),
        "scope": "profile",
        "theme": "dark",
        "onfailure": function(err){console.log("error:"+err);}
      });
    console.log("afterview: gapi started"); //this is printed 
  }

Initialization seems to have gone fine. I see console.log and button. I can enter the popup, but after that the window closes and nothing happens. Nothing is printed on the console, either successful or error messages

+4
source share
1

- . angular 2.0, Lite-, 3000. , 80, google (localhost: 3000). , google api - ( http 403?) , , , !

+5

All Articles