From 637cde474b7711b56db0452a73dbb990d110ebf2 Mon Sep 17 00:00:00 2001 From: albertony <12441419+albertony@users.noreply.github.com> Date: Thu, 23 Jun 2022 14:30:11 +0200 Subject: Disable automatic use of v2 authid for Jottacloud --- Duplicati/Library/Backend/Jottacloud/JottacloudAuthHelper.cs | 1 + Duplicati/Library/Backend/OAuthHelper/OAuthHelper.cs | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Duplicati/Library/Backend/Jottacloud/JottacloudAuthHelper.cs b/Duplicati/Library/Backend/Jottacloud/JottacloudAuthHelper.cs index d8a5d2f48..b6b4a146d 100644 --- a/Duplicati/Library/Backend/Jottacloud/JottacloudAuthHelper.cs +++ b/Duplicati/Library/Backend/Jottacloud/JottacloudAuthHelper.cs @@ -28,6 +28,7 @@ namespace Duplicati.Library.Backend : base(accessToken, "jottacloud") { base.AutoAuthHeader = true; + base.AutoV2 = false; // Jottacloud is not v2 compatible because it generates a new refresh token with every access token refresh and invalidates the old. var userinfo = GetJSONData(USERINFO_URL); if (userinfo == null || string.IsNullOrEmpty(userinfo.Username)) diff --git a/Duplicati/Library/Backend/OAuthHelper/OAuthHelper.cs b/Duplicati/Library/Backend/OAuthHelper/OAuthHelper.cs index 007376cc0..ca9212e7b 100644 --- a/Duplicati/Library/Backend/OAuthHelper/OAuthHelper.cs +++ b/Duplicati/Library/Backend/OAuthHelper/OAuthHelper.cs @@ -83,6 +83,16 @@ namespace Duplicati.Library /// Set to true if the provider does not use refresh tokens, but only access tokens /// public bool AccessTokenOnly { get; set; } + /// + /// If true (the default), when a v1 authid is being used it will be swapped + /// with a v2 authid, when the OAuth service returns one (which it dypically + /// does after a provider token refresh has been performed). Some providers + /// are not compatible with v2 authid, tyically because they generate a new + /// refresh token with every access token refresh and invalidates the old. + /// If the oauth service still returns a v2 authid for such a provider, + /// set this property to false to make Duplicati ignore it. + /// + public bool AutoV2 { get; set; } = true; public OAuthHelper(string authid, string servicename, string useragent = null) : base(useragent) @@ -134,7 +144,7 @@ namespace Duplicati.Library var res = GetTokenResponse(); m_tokenExpires = DateTime.UtcNow.AddSeconds(res.expires - 30); - if (!string.IsNullOrWhiteSpace(res.v2_authid)) + if (AutoV2 && !string.IsNullOrWhiteSpace(res.v2_authid)) m_authid = res.v2_authid; return m_token = res.access_token; } -- cgit v1.2.3