Google Authentication in Angular 6

一世执手 提交于 2019-12-06 02:07:35

The problem here is this

ngOnInit(){
 this.socialSignIn('google');
}

The injected socialAuthService of SigninComponent is not available on ngOnInit(). You can see more in Difference between Constructor and ngOnInit

Since I see a button on app.component.html. If you are trying to simulate a mouse click I would suggest using the appropriate Lifecycle Hooks

Also, delete FacebookLoginProvider and LinkedInLoginProvider in app.component.ts since there are no imports and no mention in app.module.ts

RJLyders

If the code you have posted for app.module.ts is literally what you are trying to run, please note that the constructor for GoogleLoginProvider() within getAuthServiceConfigs() {...new GoogleLoginProvider("Your-Google-Client-Id")...} is expecting you to populate it with your Google Client ID.

More specifically, please note that the client ID will look something like YOUR_CLIENT_ID.apps.googleusercontent.com where YOUR_CLIENT_ID will be a long list of digits and numbers given to you by the Google API console. This whole string YOUR_CLIENT_ID.apps.googleusercontent.com must be given to the GoogleLoginProvider() constructor.... again, with YOUR_CLIENT_ID replaced with your web site client ID from the Google API console.

If you need to obtain a client ID from Google, you can follow the following link and click the blue CONFIGURE A PROJECT button: https://developers.google.com/identity/sign-in/web/sign-in

I hope that helps. Best wishes.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!