IDENTITY-2821 authentication.endpoint

Define the StringBuilder inside try and prepare the response