我正在使用这样的星云 oauth2 谷歌登录
在我的 auth.module.ts
NbAuthModule.forRoot({
strategies: [
NbOAuth2AuthStrategy.setup({
name: 'google',
clientId: '219027435285-822fstg8ddquhag9bcu94v5vutclng42.apps.googleusercontent.com',
clientSecret: '',
authorize: {
endpoint: 'https://accounts.google.com/o/oauth2/v2/auth',
responseType: NbOAuth2ResponseType.TOKEN,
scope: 'https://www.googleapis.com/auth/userinfo.profile',
redirectUri: 'https://kewirus-v1.web.app/auth/callback',
},
}),
],
forms: {},
}),
在我的登录组件中
userPass:any;
userMail:any;
token:any;
constructor(service: NbAuthService,@Inject(NB_AUTH_OPTIONS) options: {},cd: ChangeDetectorRef, router: Router) {
super(service,options,cd, router);
}
alive = true;
login() {
this.service.authenticate('google')
.pipe(takeWhile(() => this.alive))
.subscribe((authResult: NbAuthResult) => {
console.log();
});
}
ngOnDestroy(): void {
this.alive = false;
}
在我的回调组件中
private destroy$ = new Subject<void>();
constructor(private authService: NbAuthService, private router: Router) {
this.authService.authenticate('google')
.pipe(takeUntil(this.destroy$))
.subscribe((authResult: NbAuthResult) => {
if (authResult.isSuccess()) {
this.router.navigateByUrl('../pages/dashboard');
}
});
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
它应该重定向到仪表板页面,但它重定向回登录而不是仪表板页面。我做错了什么?