Custom endpoints don't work via POST

I’m having trouble with authenticating via custom endpoints.

How do I accept POST requests in stead of GET?

I cannot accept passwords containing a “+” (plus sign).
these are translated to a " " (space) and then clearly not work.

When sending the request with POST the params are empty.

And how do I accept email in stead of username

I use this script provided by @artur

/config/user/auth.php
<?php

$user = $this->param('user');
$password = $this->param('password');

if (!$user || !$password) {
    return $this->stop(['error' => 'User and password are required'], 412);
}

$user = $this->helper('auth')->authenticate(compact('user', 'password'));

if (!$user) {
  return $this->stop(['error' => 'Authentication failed!'], 412);
}

return ['apiKey' => $user['apiKey']];

Hi, if you want to send data using POST, try to send it in this format.

{
“data”: { “name” :“USERNAEM”, “password” : “PASSWORD” }
}

Now you can access the data using

$data=$this->param(‘data’);

I am not pro at this, but this worked for me.