0
你好我想Angular2與腳本類型由their guideAngular2谷歌簽署
登錄/註銷從谷歌添加/ index.html中
<script src="https://apis.google.com/js/platform.js"></script>
在LoginComponent.ts
declare const gapi: any;
ngAfterViewInit() {
gapi.signin2.render(
this.googleLoginButtonId,
{"onSuccess": this.onGoogleLoginSuccess,"scope": "profile",
"theme": "dark"},function (error) {
console.log(JSON.stringify(error, undefined, 2));
});
}
onGoogleLoginSuccess = (loggedInUser) => {
var profile = loggedInUser.getBasicProfile();
this.auth.LoginSuccess(loggedInUser);
}
米那工作正常,但對我來說,當loginSuccess我想在那個時候我對着錯誤,如路線圖,以個人資料頁:
Uncaught TypeError: Cannot read property 'style' of null
at G_ (cb=gapi.loaded_0:282)
at H_.<anonymous> (cb=gapi.loaded_0:285)
at Function.<anonymous> (cb=gapi.loaded_0:155)
at MessagePort.c.port1.onmessage (cb=gapi.loaded_0:73)
,也是我希望整個登錄過程作爲服務或模塊重用。我如何創建這整個谷歌登錄操作作爲模塊或服務
你可以給我一個代碼片段或工作演示或建議我任何angular2模塊來實現這一點。
我也試過angular2SocialLogin模塊,但也顯示錯誤,當我製作了一些錯誤我想提git issue
請大家幫我出它提前.Thanks ..
謝謝Thabung但我希望谷歌登錄的服務或模塊我怎麼能做到這一點請幫助我... –
嗨,謝謝你的回答,我從這個[link]找到解決方案(https://stackoverflow.com/questions/35096271/how-to-implement-social-authentication-for-an-api) –