【发布时间】:2020-07-06 12:18:23
【问题描述】:
在执行 Google OAuth 流程时,可以传递加密状态 (base64),该状态将作为参数传递给最终回调。例如,当您要将用户重定向到特定页面时,这很有用。 (https://developers.google.com/identity/protocols/oauth2/web-server)
是否可以将 OAuth 状态与 Nest.js 身份验证库一起使用?似乎 state 参数被忽略了,我在文档上找不到任何东西。
@Injectable()
export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
constructor(readonly configService: ConfigService) {
super({
clientID: configService.get('google.clientId'),
clientSecret: configService.get('google.clientSecret'),
callbackURL: `${configService.get('apiUri')}${configService.get('google.callbackUrl')}`,
passReqToCallback: true,
scope: ['profile', 'email'],
});
}
}
【问题讨论】:
标签: oauth passport.js nestjs