How can I authenticate my RESTful API?

Hi guys!

I’ve build an App for Nextcloud and I need to authenticate Accounts with Basic Auth.

My approach by calling https://user:pass@server.de/index.php/apps/myapp/api/endpoint does not work. Is there something I need to know or is there a better way?

Do I have to login the user manually by calling $this->userSession->login($userId, $password)?

Any help is much apprecated!

No thougths about this? I just want to authenticate my RESTful API and I think I’m not the first one. Can I generate an App-Password and give it as parameter to the url?

The Documentation is realy not that good, so I thought someone has an idea.

I haven’t done anything with this myself but I think the clean solution would be to use the oauth2 app that comes with Nextcloud 13. You might want to look into that. Passing a password as a parameter in the url is afaik a massive code smell.

If by “App” you mean a server app, you might be able to use a php open id connect library. Afaik this is the state-of-the-art authentication mechanism for APIs and web applications in general.