Can't log into 1.2 API using a 2FA-enabled account

Hello everyone.
I’m trying to create my own news application by downloading the feed from my NextCloud instance; for this I’m studying the News plugin API using the official documentation I found on GitHub.
The problem arises when I try to log in using API 1.2 (apparently the only one available on my installation): in fact, if I try to send the base64-encoded Authorization: username:password header as explained in the documentation, the server replies that it’s not possible to authenticate with a password and that I need to use a token ({"message": "Password login forbidden, use token instead"}). I have therefore tried both manually generating an “application password” and a token received with OAuth2, but neither of the two methods worked (the first returned the same exact message while the second even caused an HTTP 500 error).
So I’m wondering: how can I use the API by accessing my account with two-factor authentication? I suppose this is possible since I already use an app on my Android device without any particular problems…
Thank you in advance for your help.

Hey

so yes I guess that is possible, you need to deal with the oauth authentication from the server.
If you build the app for Android you may use the Nextcloud app for that, check how the News Android client does it.

Alternatively you can generate an app password in your security settings, that should allow you to simply use username+app password in your app.

This doesn’t have to do much with the news app itself as authentication is fully done by the server the docs are quite old and so they only have a simple example.

btw documentation moved an has some styling now Developer - Nextcloud News App