If you are having below error in duplicity probably your token has expired and you need to generate a new one.
oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) The user could not be authenticated as the grant is expired. The user must sign in again.
To generate a new one simply run duplicity and follow the steps, you are going to see something similar to:
+ duplicity remove-older-than 1M onedrive://Duplicity_backups/usr_local_etc
Could not load OAuth2 token. Trying to create a new one. (original error: [Errno 2] No such file or directory: '/root/.duplicity_onedrive_oauthtoken.json')
In order to authorize duplicity to access your OneDrive, please open https://login.live.com/oauth20_authorize.srf?response_type=code&client_id=YOURID&redirect_uri=https%3A%2F%2Flogin.live.com%2Foauth20_desktop.srf&scope=Files.Read+Files.ReadWrite+User.Read+offline_access&state=YOURSECRETKEY&display=touch in a browser and copy the URL of the blank page the dialog leads to.
URL of the blank page: https://login.live.com/oauth20_desktop.srf?code=YOURCODE5&state=YOURSERET=NUMBERS
In case you need any help drop a comment.
A good how to configure duplicity with OneDrive can be found here: https://blog.xmatthias.com/duplicity-onedrive/, you can apply the same if you are using FreeBSD.
2022.02.12 – Update: as John pointed out in the comment, renaming or removing .duplicity_onedrive_oauthtoken.json can trigger duplicity to run a new OneDrive configuration.
Doesn’t work for me. All Duplicity commands fail with same error!
It’s easy… Just remove
.duplicity_onedrive_oauthtoken
in your home dir
Yes, that definitely helps.
I did keep my old one, just in case. Let me update this page with the info.
Thank you John!