我使用下面的 swagger 配置进行 Keycloak 身份验证。
const swaggerConfig = new DocumentBuilder()
.addOAuth2({
type: 'oauth2',
flows: {
implicit: {
authorizationUrl: 'http://localhost:8080/realms/hello/protocol/openid-connect/auth',
tokenUrl: 'http://localhost:8080/realms/hello/protocol/openid-connect/token',
scopes: {}
}
}
})
.build();
当我执行工作流程时,系统会提示我在 Keycloak 中输入用户名和密码。身份验证成功后,我收到错误屏幕。
该网址包含正确的信息。
http://localhost:3300/api/oauth2-redirect.html#state=VGh1IEZ...aW1lKQ%3D%3D&session_state=679b34f5-61f5-4f45-810f-712de907cf7c&access_token=eyJhbGciOiJS...M4In0&token_type=Bearer&expires_in=900
NestJS 中使用 Keycloak 进行 Swagger 身份验证有什么问题吗?
如果默认在“localhost:3300/api/swagger/”或“localhost:3300/api/”末尾添加斜杠,则重定向网址将被正确配置。另请参阅https://github.com/nestjs/swagger/issues/2024