From 6e38096f1a7be3607ce373af1577335093513a09 Mon Sep 17 00:00:00 2001 From: Remi Rousselet Date: Fri, 20 Oct 2023 12:15:25 +0200 Subject: [PATCH] Improve login fail message Fixes #572 --- googleapis_auth/lib/auth_io.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/googleapis_auth/lib/auth_io.dart b/googleapis_auth/lib/auth_io.dart index f99f70e85..9e60f7662 100644 --- a/googleapis_auth/lib/auth_io.dart +++ b/googleapis_auth/lib/auth_io.dart @@ -92,7 +92,18 @@ Future clientViaApplicationDefaultCredentials({ ); } - return await clientViaMetadataServer(baseClient: baseClient); + try { + return await clientViaMetadataServer(baseClient: baseClient); + } on Exception catch (err, stack) { + Error.throwWithStackTrace( + Exception( + 'Failed to load Application Default Credentials. ' + 'Make sure you are logged in with `firebase` or `gcloud` CLI, ' + 'or your code is running on Google Compute Engine/Google App Engine.', + ), + stack, + ); + } } /// Obtains oauth2 credentials and returns an authenticated HTTP client.