HTTP login with Nextcloud credentials

Hi, I want to re-use the credentials from Nextcloud for my custom scripts, outside of Nextcloud, rather than create a new credentials for them.

How can I do that?

curl -u "username:password" https://....
First use will return a cookie that you can append to subsequent requests to maintain authentication.
Some functions (api) of nextcloud require an application-specific password, which you can either generate within nextcloud (Settings → Personal → Security), or with Login Flow — Nextcloud latest Developer Manual latest documentation

Many thanks !

For anyone want to know, there is my PHP code to know if a username/password working.



$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Basic ".base64_encode($username.":".$password),"OCS-APIRequest: true",]);
$result=curl_exec ($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);   //get status code
curl_close ($ch);

if (mb_ereg("ok", $result)) echo "Valid";