Skip to content

Commit c5005e9

Browse files
praveenkuttappanazure-sdk
authored andcommitted
Add erro handling for gh auth token
1 parent 922757b commit c5005e9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

eng/common/scripts/Helpers/AzSdkTool-Helpers.ps1

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,14 @@ function isNewVersion(
108108
function Get-GitHubApiHeaders {
109109
# Use GitHub cli to get an auth token if available
110110
if (Get-Command gh -ErrorAction SilentlyContinue) {
111-
$token = gh auth token 2>$null
111+
try
112+
{
113+
$token = gh auth token 2>$null
114+
}
115+
catch
116+
{
117+
Write-Host "Failed to get GitHub CLI auth token."
118+
}
112119
}
113120

114121
# Get token from env if not available from gh cli
@@ -122,7 +129,7 @@ function Get-GitHubApiHeaders {
122129
{
123130
Write-Host "Using authenticated GitHub API requests."
124131
$headers = @{
125-
Authorization = "Bearer $tokentest"
132+
Authorization = "Bearer $token"
126133
}
127134
return $headers
128135
}

0 commit comments

Comments
 (0)