谷歌角度社交日志记录错误。用户关闭的弹出窗口

时间:2019-02-21 06:59:27

标签: angular

在这里,我正在尝试将Google登录信息与angular集成起来

我正在使用 angular6-social-login

的软件包

Facebook登录正常,但 对于Google,即使我正在关闭,它也会自动显示用户关闭的弹出窗口

app.module.ts

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import {
SocialLoginModule,
AuthServiceConfig,
GoogleLoginProvider,
FacebookLoginProvider,
LinkedinLoginProvider
} from "angular-6-social-login";


import { AppComponent } from './app.component';


const config = new AuthServiceConfig(
[
    {
    id: GoogleLoginProvider.PROVIDER_ID,
    provider: new GoogleLoginProvider('163029070014-jng0k5e6nr2msctqp6it2f4hiqs8cb1k.apps.googleusercontent.com')

    },
    {
    id: FacebookLoginProvider.PROVIDER_ID,
    provider: new FacebookLoginProvider('272781596707491')
    },
    {
    id: LinkedinLoginProvider.PROVIDER_ID,
    provider: new LinkedinLoginProvider('77emt6ok070g9q')
    }
]
);

export function provideConfig() {
return config;
}


@NgModule({
declarations: [
    AppComponent
],
imports: [
    BrowserModule,
    SocialLoginModule
],
providers: [
    { provide: AuthServiceConfig, useFactory: provideConfig },
],
bootstrap: [AppComponent]
})
export class AppModule { }

app.component.ts

import {Component, OnInit} from '@angular/core';
import {
    AuthService,
    FacebookLoginProvider,
    GoogleLoginProvider,
    LinkedinLoginProvider
} from "angular-6-social-login";


@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})



export class AppComponent implements OnInit {





constructor( private socialAuthService: AuthService ) {}

ngOnInit(){

}

public socialSignIn(socialPlatform : string) {
    let socialPlatformProvider;
    if(socialPlatform == "facebook"){
    socialPlatformProvider = FacebookLoginProvider.PROVIDER_ID;
    }else if(socialPlatform == "google"){
    socialPlatformProvider = GoogleLoginProvider.PROVIDER_ID;
    } else if (socialPlatform == "linkedin") {
    socialPlatformProvider = LinkedinLoginProvider.PROVIDER_ID;
    }


    this.socialAuthService.signIn(socialPlatformProvider).then(
    (userData) => {
        console.log(socialPlatform+" sign in data : " , userData);
        // Now sign-in with userData
        // ...

    }
    );
}

}



app.component.html


    <h1>
    Sign in
    </h1>

    <button (click)="socialSignIn('facebook')">Sign in with Facebook</button>
    <button (click)="socialSignIn('google')">Sign in with Google</button>
    <button (click)="socialSignIn('linkedin')">Sign in with linkedin</button>

我已将Oauth重新重定向网址添加为 http://localhost

它正在显示弹出窗口,并自动消失,并显示错误用户关闭了弹出窗口

0 个答案:

没有答案