Skip to content

Commit

Permalink
ENG-2677 Better error-handling of expired token (#115)
Browse files Browse the repository at this point in the history
Improved the error-handling if 'gcloud auth print-access-token' does not
return a valid access token.
  • Loading branch information
fabgo authored Sep 26, 2024
1 parent a39944e commit b2e854a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/plugins/google/ssh-key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,15 @@ export const importSshKey = async (
});

if (!response.ok) {
throw `Import of SSH public key failed. HTTP error ${response.status}: ${await response.text()}`;
if (debug) {
print2(`HTTP error ${response.status}: ${await response.text()}`);
}

if (response.status === 401) {
throw `Authentication failed. Please login to Google Cloud CLI with 'gcloud auth login'`;
} else {
throw `Import of SSH public key failed.`;
}
}

const data: ImportSshPublicKeyResponse = await response.json();
Expand Down

0 comments on commit b2e854a

Please sign in to comment.