Getting JSon Web Token from Nextcloud server

Hello! I’m developing an Android app that interacts with a Nextcloud server. I’m utilizing a WebView for the login process, following the guidelines outlined in the Nextcloud documentation: https://docs.nextcloud.com/…/clien…/LoginFlow/index.html

  1. What’s the recommended approach to obtain this token, and how can I securely store it for subsequent API calls?

  2. How to achieve file upload and download using the Nextcloud API?

Your assistance in these matters would be greatly appreciated. Thank you!