API authentication in Version 16

Nextcloud

Version: 16.0.4.1

Apps installed: 42

Apps updates available: 0

PHP

Version: 7.2.10

The problem is that I am not able to access the user API from an external tool.

I tried to access the API with my normal username and password:
‘curl https://myloginname:mypassword@cloud.server.de/ocs/v1.php/cloud/user -H “OCS-APIRequest: true”’

I also tried to add a app password and use this to access the API.

Butall the time I get this error:

<?xml version="1.0"?>
<ocs>
 <meta>
  <status>failure</status>
  <statuscode>997</statuscode>
  <message>Current user is not logged in</message>
  <totalitems></totalitems>
  <itemsperpage></itemsperpage>
 </meta>
 <data/>
</ocs>

What is the best way to create access tokens for external clients. And do I have to activate or disable any service/ security system?