diff --git a/Controller.php b/Controller.php index 99f83c3d8..13982ba80 100644 --- a/Controller.php +++ b/Controller.php @@ -15,17 +15,9 @@ use Piwik\Date; use Piwik\Nonce; use Piwik\Notification; -use Piwik\Option; use Piwik\Piwik; use Piwik\Plugins\GoogleAnalyticsImporter\Commands\ImportReports; use Piwik\Plugins\GoogleAnalyticsImporter\Google\Authorization; -use Piwik\Plugins\SearchEngineKeywordsPerformance\Exceptions\MissingClientConfigException; -use Piwik\Plugins\SearchEngineKeywordsPerformance\Exceptions\MissingOAuthConfigException; -use Piwik\Plugins\SearchEngineKeywordsPerformance\Provider\Google as ProviderGoogle; -use Piwik\Plugins\SearchEngineKeywordsPerformance\Provider\Bing as ProviderBing; -use Piwik\Plugins\SearchEngineKeywordsPerformance\Provider\ProviderAbstract; -use Piwik\Plugins\WebsiteMeasurable\Type as WebsiteMeasurableType; -use Piwik\Site; use Piwik\Url; use Psr\Log\LoggerInterface; @@ -51,7 +43,13 @@ public function index($errorMessage = false) $hasClientConfiguration = $authorization->hasClientConfiguration(); if ($hasClientConfiguration) { - $googleClient = $authorization->getConfiguredClient(); + try { + $googleClient = $authorization->getConfiguredClient(); + } catch (\Exception $ex) { + $authorization->deleteClientConfiguration(); + + throw $ex; + } $authUrl = $googleClient->createAuthUrl(); diff --git a/lang/en.json b/lang/en.json index 9e69621eb..3016d0b57 100644 --- a/lang/en.json +++ b/lang/en.json @@ -3,7 +3,7 @@ "AdminMenuTitle": "Google Analytics Import", "ConfigureTheImporter": "Configure the Importer", "InvalidClientJson": "Invalid JSON in credentials file, try re-downloading the file from the Google API Console.", - "MissingClientConfiguration": "Missing client configuration.", + "MissingClientConfiguration": "Missing or invalid client configuration, please reupload.", "SettingUp": "Setting Up", "ImporterHelp1": "The Google Analytics Importer requires you to set up OAuth Client configuration in the Google API Console before you can do anything else.", "ImporterHelp2": "To see a step-by-step guide for doing this and setting up this plugin %1$sclick here.%2$s",