My code is here
component.ts
- import { Component, Injectable, OnInit } from '@angular/core';
- import { GoogleLoginProvider, FacebookLoginProvider, AuthService } from 'angular-6-social-login';
- import { SocialLoginModule, AuthServiceConfig } from 'angular-6-social-login';
- declare var FB: any
- @Component({
- selector: 'app-signup',
- templateUrl: './signup.component.html',
- styleUrls: ['./signup.component.css']
- })
- export class SignupComponent implements OnInit {
- toastr: any;
- auth2: any;
- constructor( public authService: AuthService
- ) { }
- ngOnInit(): void {
- (window as any).fbAsyncInit = function () {
- FB.init({
- appId: '277072117153996',
- cookie: true,
- xfbml: true,
- version: 'v3.10'
- });
- FB.AppEvents.logPageView();
- };
- (function (d, s, id) {
- var js, fjs = d.getElementsByTagName(s)[0];
- if (d.getElementById(id)) { return; }
- js = d.createElement(s); js.id = id;
- js.src = "https://connect.facebook.net/en_US/sdk.js";
- fjs.parentNode.insertBefore(js, fjs);
- }(document, 'script', 'facebook-jssdk'));
- }
- fblogin() {
- console.log("submit login to facebook");
- // FB.login();
- FB.login((response) => {
- console.log('submitLogin', response);
- if (response.authResponse) {
- console.log('login successful', 'Success!');
- }
- else {
- console.log('User login failed');
- }
- });
- }
- Google_signin() {
- let socialPlatformProvider;
- socialPlatformProvider = GoogleLoginProvider.PROVIDER_ID;
- this.authService.signIn(socialPlatformProvider).then(google_user => {
- console.log(google_user);
- })
- }
- Upload_img() {
- }
- }
Module.ts
- import { NgModule } from '@angular/core';
- import { FormsModule } from '@angular/forms';
- import { BrowserModule } from '@angular/platform-browser';
- import { RouterModule, Routes } from '@angular/router';
- import { AppComponent } from './app.component';
- import { SignupComponent } from './signup/signup.component';
- import { HomeComponent } from './home/home.component';
- import {HttpClientModule} from '@angular/common/http';
- import { AuthService, GoogleLoginProvider } from 'angular-6-social-login';
- import { SocialLoginModule, AuthServiceConfig } from 'angular-6-social-login';
- export function socialConfigs() {
- const config = new AuthServiceConfig(
- [
- {
- id: GoogleLoginProvider.PROVIDER_ID,
- provider: new GoogleLoginProvider('149457059037-t9i75j5mnrmvguoq6795s6ausudmsgq4.apps.googleusercontent.com')
- }
- ]
- );
- return config;
- }
- const ROUTES:Routes=[
- {path:"signup",component:SignupComponent}
- ]
- @NgModule({
- declarations: [
- AppComponent,
- SignupComponent,
- HomeComponent
- ],
- imports: [
- BrowserModule,
- RouterModule.forRoot(ROUTES),
- FormsModule,
- HttpClientModule
- ],
- providers: [
- AuthService,
- {
- provide: AuthServiceConfig,
- useFactory: socialConfigs
- }
- ],
- bootstrap: [AppComponent]
- })
- export class AppModule { }
Preetham HolenarasipuradeveraPosted Mar 16, 2021, 10:22 AM
Preetham HolenarasipuradeveraPosted Mar 16, 2021, 10:19 AM
Satya KarkiPosted Mar 16, 2021, 8:47 AM
Rijwan AnsariPosted Mar 16, 2021, 8:42 AM
Siddharth GajbhiyePosted Mar 16, 2021, 5:30 AM