Hello!
You can enable the API for your customers, by setting the value of api_allow_customer tweak to true:
$config['tweaks']['api_allow_customer'] = true;
in the config.local.php file or in its override, local_conf.php.
Then your customers can receive the token by sending POST request with login and password to the auth_tokens API entity. For example:
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => “http://localhost/api/auth_tokens/”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => ‘{“email”: “customer@example.com”,“password”: “customer”}’,
CURLOPT_HTTPHEADER => [
“Content-Type: application/json”
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo “cURL Error #:” . $err;
} else {
echo $response;
}
The received token later can be used for authentication. Instead of usage of pair email and API-key in the basic auth, you will be able to simply send the token in the User field of basic auth.
As for the deleting the the customer account by his/her own request, you will need to create separate API entity that will make possible to make such an action.
Hope it helps.