I had posted this in a different forum last week but gotten no response so I am posting it here:
Using RStudio on Ubuntu, I am asked to input my GitHub token regularly (it looks like it resets every 60 minutes) even though it is stored correctly. That is when I check .git-credentials and with gitcreds::gitcreds_set() what credentials are stored, it is the right username and token.
Probably because you are using the default cache credential helper. You can increase the default timeout, or use a different helper, see here: https://git-scm.com/doc/credential-helpers
gitcreds can use env vars instead of proper credentials, see the gitcreds docs.