diff --git a/TeslaSolarCharger/Server/Resources/PossibleIssues/Contracts/IIssueKeys.cs b/TeslaSolarCharger/Server/Resources/PossibleIssues/Contracts/IIssueKeys.cs index c8e44a964..72ca52cfb 100644 --- a/TeslaSolarCharger/Server/Resources/PossibleIssues/Contracts/IIssueKeys.cs +++ b/TeslaSolarCharger/Server/Resources/PossibleIssues/Contracts/IIssueKeys.cs @@ -9,6 +9,7 @@ public interface IIssueKeys string FleetApiTokenRequestExpired { get; } string FleetApiTokenNotReceived { get; } string FleetApiTokenExpired { get; } + string FleetApiTokenRefreshNonSuccessStatusCode { get; } string FleetApiTokenNoApiRequestsAllowed { get; } string CrashedOnStartup { get; } string RestartNeeded { get; } @@ -19,7 +20,6 @@ public interface IIssueKeys string FleetApiNonSuccessStatusCode { get; } string FleetApiNonSuccessResult { get; } string UnsignedCommand { get; } - string FleetApiTokenRefreshNonSuccessStatusCode { get; } string CarRateLimited { get; } string BleCommandNoSuccess { get; } string SolarValuesNotAvailable { get; } diff --git a/TeslaSolarCharger/Server/Resources/PossibleIssues/IssueKeys.cs b/TeslaSolarCharger/Server/Resources/PossibleIssues/IssueKeys.cs index 7e204503b..965c98307 100644 --- a/TeslaSolarCharger/Server/Resources/PossibleIssues/IssueKeys.cs +++ b/TeslaSolarCharger/Server/Resources/PossibleIssues/IssueKeys.cs @@ -10,6 +10,7 @@ public class IssueKeys : IIssueKeys public string FleetApiTokenMissingScopes => "FleetApiTokenMissingScopes"; public string FleetApiTokenRequestExpired => "FleetApiTokenRequestExpired"; public string FleetApiTokenNotReceived => "FleetApiTokenNotReceived"; + public string FleetApiTokenRefreshNonSuccessStatusCode => "FleetApiTokenRefreshNonSuccessStatusCode"; public string FleetApiTokenExpired => "FleetApiTokenExpired"; public string FleetApiTokenNoApiRequestsAllowed => "FleetApiRequestsNotAllowed"; public string CrashedOnStartup => "CrashedOnStartup"; @@ -21,7 +22,6 @@ public class IssueKeys : IIssueKeys public string FleetApiNonSuccessStatusCode => "FleetApiNonSuccessStatusCode_"; public string FleetApiNonSuccessResult => "FleetApiNonSuccessResult_"; public string UnsignedCommand => "UnsignedCommand"; - public string FleetApiTokenRefreshNonSuccessStatusCode => "FleetApiTokenRefreshNonSuccessStatusCode"; public string CarRateLimited => "CarRateLimited"; public string BleCommandNoSuccess => "BleCommandNoSuccess_"; public string SolarValuesNotAvailable => "SolarValuesNotAvailable"; diff --git a/TeslaSolarCharger/Server/Services/BackendApiService.cs b/TeslaSolarCharger/Server/Services/BackendApiService.cs index 1d24cd3b8..5db2c5714 100644 --- a/TeslaSolarCharger/Server/Services/BackendApiService.cs +++ b/TeslaSolarCharger/Server/Services/BackendApiService.cs @@ -31,10 +31,10 @@ public async Task> StartTeslaOAuth(string locale, string baseUr logger.LogTrace("{method}()", nameof(StartTeslaOAuth)); var currentTokens = await teslaSolarChargerContext.TeslaTokens.ToListAsync().ConfigureAwait(false); teslaSolarChargerContext.TeslaTokens.RemoveRange(currentTokens); - var cconfigEntriesToRemove = await teslaSolarChargerContext.TscConfigurations + var configEntriesToRemove = await teslaSolarChargerContext.TscConfigurations .Where(c => c.Key == constants.TokenMissingScopes) .ToListAsync().ConfigureAwait(false); - teslaSolarChargerContext.TscConfigurations.RemoveRange(cconfigEntriesToRemove); + teslaSolarChargerContext.TscConfigurations.RemoveRange(configEntriesToRemove); await teslaSolarChargerContext.SaveChangesAsync().ConfigureAwait(false); var installationId = await tscConfigurationService.GetInstallationId().ConfigureAwait(false); var backendApiBaseUrl = configurationWrapper.BackendApiBaseUrl(); @@ -63,7 +63,13 @@ public async Task> StartTeslaOAuth(string locale, string baseUr await errorHandlingService.HandleError(nameof(BackendApiService), nameof(StartTeslaOAuth), "Waiting for Tesla token", "Waiting for the Tesla Token from the TSC backend. This might take up to five minutes. If after five minutes this error is still displayed, open the Base Configuration and request a new token.", issueKeys.FleetApiTokenNotReceived, null, null); + //Do not set FleetApiTokenNotReceived to resolved here, as the token might still be in transit await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenNotRequested, null); + await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenUnauthorized, null); + await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenMissingScopes, null); + await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenRequestExpired, null); + await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenExpired, null); + await errorHandlingService.HandleErrorResolved(issueKeys.FleetApiTokenRefreshNonSuccessStatusCode, null); return new DtoValue(requestUrl); }