Symfony 5 DELETE request Full authentication is required to access this resource

With the JWT, I manage to get the token of a User who has the ROLE_ADMIN but when I want to delete a user, it says: "Full authentication is required to access this resource."

Here is a piece of my code in the User class:

**
 * @ORMEntity(repositoryClass=UserRepository::class)
 * @ApiResource(
 *  normalizationContext={
 *      "groups"={"availabilities_read"}
 *  },
 *  collectionOperations={
 *      "post"={"path"="/user"},
 *  },
 *  itemOperations={
 *         "get"={"path"="/user/{id}"},
 *         "put"={"path"="/user/{id}"},
 *         "delete"={"path"="/user/{id}", "security"="is_granted('ROLE_ADMIN')"},
 *  }
 * )
 */
class User implements UserInterface

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *