Skip to content
Advertisement

How can i access Client data into custom Normalizer (Symfony 4)

I’m trying to create a custom normalizer, but I cannot access to my current user using API Platform.

When I try to load my Client class, this is empty. I tried to method using the API Platform’s documentation, but the retreived token is empty too.

Do you have any tip to get my current user ? Thanks

JavaScript

Advertisement

Answer

Have you tried to inject TokenInterface on your class ?

JavaScript

Then you can use $token->getUser() to retrieve your current user.

if you don’t have a user then you don’t use your API with authentication. See https://api-platform.com/docs/core/jwt/

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement