diff --git a/security/login_link.rst b/security/login_link.rst
index b92dd694178..e43edbd7a22 100644
--- a/security/login_link.rst
+++ b/security/login_link.rst
@@ -654,3 +654,85 @@ user create this POST request (e.g. by clicking a button)::
{% endblock %}
+
+Customizing the Success Handler
+...............................
+
+To customize, how the success handler behaves, create your own ``AuthenticationSuccessHandler``::
+
+ // src/Security/Authentication/AuthenticationSuccessHandler.php
+ namespace App\Security\Authentication;
+
+ use Symfony\Component\HttpFoundation\JsonResponse;
+ use Symfony\Component\HttpFoundation\Request;
+ use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+ use Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface;
+
+ class AuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
+ {
+ public function onAuthenticationSuccess(Request $request, TokenInterface $token): JsonResponse
+ {
+ // Example use case: Create API token for Guard Authentication.
+ $user = $token->getUser(); // Returns string|\Stringable|UserInterface - depends on your implementation.
+
+ $userApiToken = $user->getApiToken();
+
+ return new JsonResponse(['apiToken' => 'userApiToken']);
+ }
+ }
+
+Modify the configuration and use your handler for the ``success_handler`` key:
+
+.. configuration-block::
+
+ .. code-block:: yaml
+
+ # config/packages/security.yaml
+ security:
+ firewalls:
+ main:
+ login_link:
+ check_route: login_check
+ lifetime: 600
+ max_uses: 1
+ success_handler: App\Security\Authentication\AuthenticationSuccessHandler
+
+ .. code-block:: xml
+
+
+
+
+
+
+
+
+
+
+
+
+ .. code-block:: php
+
+ // config/packages/security.php
+ $container->loadFromExtension('security', [
+ 'firewalls' => [
+ 'main' => [
+ 'login_link' => [
+ 'check_route' => 'login_check',
+ 'lifetime' => 600,
+ 'max_uses' => 1,
+ 'success_handler' => 'App\Security\Authentication\AuthenticationSuccessHandler',
+ ],
+ ],
+ ],
+ ]);