adding new validation method using HookEventDispatcherInterface::FORM_ALTER event
You can do it that way too:
in Oriented object way don't call the method like 'my_api_authentication' it should be [$this, 'myApiAuthentication'] and also the method should be Camel Cases, try with the following:

class MyFormEventsSubscriber implements EventSubscriberInterface {

  public static function getSubscribedEvents() {
    return [HookEventDispatcherInterface::FORM_ALTER =&gt; 'alterForm'];
  }

  public function alterForm(FormAlterEvent $event) {
    if ($event-&gt;getFormId() == 'user_login_form') {
      $form = &amp;$event-&gt;getForm();
      $form['#validate'][] = [$this, 'myApiAuthentication'];
    }
  }
  function myApiAuthentication(&amp;$form, FormStateInterface $form_state) {
    // Your code validation here.
  }

}