import { KeycloakAuthGuard } from '../auth/keycloak.guard'; import { ProfileService } from './profile.service'; import { Controller, Get, UseGuards, Request } from '@nestjs/common'; import { AuthGuard } from '@nestjs/passport'; @Controller('profile') export class ProfileController { constructor(private readonly profileService: ProfileService) {} @UseGuards(AuthGuard('keycloak')) @Get() getProfile(@Request() req) { // The 'user' object here is exactly what you returned from validate() return { email: req.user.email, name: req.user.name, picture: req.user.picture, email_verified: req.user.email_verified, roles: req.user.roles, }; } }