Nextcloudcmd: Use authentication from nextcloud client

Hi, I’m using the nextcloud 2.6.0 client on Linux to synchronize the directory ~/Nextcloud to my Nextcloud. My Nextcloud is configured to use two-factor authentification.

I now also want to use nextcloudcmd from a script to occasionally force a sync (before and after suspending my system…). However, I see two problems:

  • nextcloudcmd asks for my credentials when running. I don’t want to hard-code my password anywhere.
  • Even if I where to hard-code my password in the script, nextcloudcmd fails to synchronize, since it can’t get a second-factor auth.

It feels to me like nextcloudcmd should be able to use the authentication token stored by the main nextcloud client. Is that possible? If yes, how?