Skip to content

Commit 0af156e

Browse files
azure-sdkscbedd
andauthored
Revert "Use authenticated GitHub request when env variable is present (#12267)" (#52993)
This reverts commit d60198ec38489bc37b8544484519b638d4fa7eca. Co-authored-by: Scott Beddall <[email protected]>
1 parent fbafe5b commit 0af156e

File tree

1 file changed

+2
-36
lines changed

1 file changed

+2
-36
lines changed

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

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -105,39 +105,6 @@ function isNewVersion(
105105
return $true
106106
}
107107

108-
function Get-GitHubApiHeaders {
109-
# Use GitHub cli to get an auth token if available
110-
$token = ""
111-
if (Get-Command gh -ErrorAction SilentlyContinue) {
112-
try
113-
{
114-
$token = gh auth token 2>$null
115-
}
116-
catch
117-
{
118-
Write-Host "Failed to get GitHub CLI auth token."
119-
}
120-
}
121-
122-
# Get token from env if not available from gh cli
123-
if (!$token)
124-
{
125-
Write-Host "Checking for GITHUB_TOKEN environment variable."
126-
$token = $env:GITHUB_TOKEN
127-
}
128-
129-
if ($token)
130-
{
131-
Write-Host "Using authenticated GitHub API requests."
132-
$headers = @{
133-
Authorization = "Bearer $token"
134-
}
135-
return $headers
136-
}
137-
Write-Host "Using unauthenticated GitHub API requests."
138-
return @{}
139-
}
140-
141108
<#
142109
.SYNOPSIS
143110
Installs a standalone version of an engsys tool.
@@ -168,12 +135,11 @@ function Install-Standalone-Tool (
168135
}
169136

170137
$tag = "${Package}_${Version}"
171-
$headers = Get-GitHubApiHeaders
172138

173139
if (!$Version -or $Version -eq "*") {
174140
Write-Host "Attempting to find latest version for package '$Package'"
175141
$releasesUrl = "https://api.github.com/repos/$Repository/releases"
176-
$releases = Invoke-RestMethod -Uri $releasesUrl -Headers $headers
142+
$releases = Invoke-RestMethod -Uri $releasesUrl
177143
$found = $false
178144
foreach ($release in $releases) {
179145
if ($release.tag_name -like "$Package*") {
@@ -197,7 +163,7 @@ function Install-Standalone-Tool (
197163

198164
if (isNewVersion $version $downloadFolder) {
199165
Write-Host "Installing '$Package' '$Version' to '$downloadFolder' from $downloadUrl"
200-
Invoke-WebRequest -Uri $downloadUrl -OutFile $downloadLocation -Headers $headers
166+
Invoke-WebRequest -Uri $downloadUrl -OutFile $downloadLocation
201167

202168
if ($downloadFile -like "*.zip") {
203169
Expand-Archive -Path $downloadLocation -DestinationPath $downloadFolder -Force

0 commit comments

Comments
 (0)