通过 Google 进行 angularx-social-login 在 Opera 中不起作用

问题描述

我在 Angular 中通过谷歌测试了 OAuth。我编写了以下代码以进行简单授权。但由于某种原因,它在 Opera 中引发了错误。但在谷歌浏览器中,Edge 可以完美运行。也许有人有同样的问题

enter image description here

我在 app.module.ts

中有以下代码
import { NgModule } from '@angular/core';
import { browserModule } from '@angular/platform-browser';
import {HttpClientModule} from "@angular/common/http"
import {FormsModule} from "@angular/forms"

import { AppComponent } from './app.component';
import { AppRoutingModule } from './app-routing.module';
import {LoginComponent} from "./login/login.component"

import {SocialAuthServiceConfig,SocialLoginModule,GoogleLoginProvider } from 'angularx-social-login';



@NgModule({
  declarations: [
    AppComponent,LoginComponent
  ],imports: [
    browserModule,AppRoutingModule,HttpClientModule,FormsModule
  ],providers: [
    {
      provide: 'SocialAuthServiceConfig',useValue: {
        autoLogin: false,providers: [
          {
            id: GoogleLoginProvider.PROVIDER_ID,provider: new GoogleLoginProvider(
              '324093147269-l4aepli8cfokli5fuiotn9huekmjugq7.apps.googleusercontent.com'
            )
          }
        ]
      } as SocialAuthServiceConfig,}
  ],bootstrap: [AppComponent]
})
export class AppModule { }

使用简单的app.component.html

<h2>fsdnklflsdkfn</h2>
<app-login></app-login>

login.component.ts

import { Component,OnInit } from '@angular/core';
import {SocialAuthService } from 'angularx-social-login';
import {SocialUser,GoogleLoginProvider } from 'angularx-social-login';

@Component({
  selector: 'app-login',templateUrl: './login.component.html',styleUrls: ['./login.component.css']
})
export class LoginComponent implements OnInit {

  user:SocialUser=new SocialUser();
  constructor(private socialAuthService: SocialAuthService) 
  {
    this.socialAuthService.authState.subscribe((user)=>{
      this.user=user;
      console.log("aadas");
    })
   }

  ngOnInit() {
      this.socialAuthService.authState.subscribe((user)=>{
      this.user=user;
      console.log("aadas");
    })
  } 
  signInWithGoogle(){
    this.socialAuthService.signIn(GoogleLoginProvider.PROVIDER_ID)
  console.log("aadas");
  }
  signOut(){
    this.socialAuthService.signOut();
  }
}

login.component.html

<div *ngIf="!user" class="card text-center">
  <h6 class="card-header">Google login</h6>
  <div class="card-clock">
    <h4 class="card-title">Not Signed in</h4>
    <p class="card-text">Sign in</p>
  </div>
</div>
<div class="card-block">
  <button (click)="signInWithGoogle()">Sign in</button>
</div>


<div *ngIf="user" class="card text-center">
  <h6 class="card-header">Google login</h6>
  <div class="card-clock">
    <h4 class="card-title">{{user.email}}</h4>
    <p class="card-text">{{user.authToken}}</p>
  </div>
</div>
<div class="card-block">
  <button (click)="signOut()">Sign out</button>
</div> 

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...