diff --git a/Duplicati/Library/Backend/OAuthHelper/OAuthHelper.cs b/Duplicati/Library/Backend/OAuthHelper/OAuthHelper.cs
index a4ba4205b..f374ab148 100644
--- a/Duplicati/Library/Backend/OAuthHelper/OAuthHelper.cs
+++ b/Duplicati/Library/Backend/OAuthHelper/OAuthHelper.cs
@@ -25,7 +25,7 @@ namespace Duplicati.Library
{
private string m_token;
private string m_authid;
- private DateTime m_tokenExpires = DateTime.UtcNow;
+ private DateTime m_tokenExpires = DateTime.UtcNow;
private static string _override_server = null;
@@ -45,7 +45,14 @@ namespace Duplicati.Library
return string.Format(addr.ToString(), modulename);
}
+ ///
+ /// Set to true to automatically add the Authorization header to requets
+ ///
public bool AutoAuthHeader { get; set; }
+ ///
+ /// Set to true if the provider does not use refresh tokens, but only access tokens
+ ///
+ public bool AccessTokenOnly { get; set; }
public OAuthHelper(string authid, string servicename, string useragent = null)
: base(useragent)
@@ -78,6 +85,9 @@ namespace Duplicati.Library
{
get
{
+ if (AccessTokenOnly)
+ return m_authid;
+
if (m_token == null || m_tokenExpires < DateTime.UtcNow)
{
var retries = 0;
@@ -132,6 +142,19 @@ namespace Duplicati.Library
}
}
+ public void ThrowOverQuotaError()
+ {
+ throw new Exception(Strings.OAuthHelper.OverQuotaError);
+ }
+
+ public void ThrowAuthException(string msg, Exception ex)
+ {
+ if (ex == null)
+ throw new Exception(Strings.OAuthHelper.AuthorizationFailure(msg, OAuthLoginUrl));
+ else
+ throw new Exception(Strings.OAuthHelper.AuthorizationFailure(msg, OAuthLoginUrl), ex);
+ }
+
private class OAuth_Service_Response