Skip to content

Commit 352c1d8

Browse files
AlitzelMendezazure-sdk
authored andcommitted
Keep migration to new endpoint
1 parent 03173b3 commit 352c1d8

File tree

1 file changed

+17
-34
lines changed

1 file changed

+17
-34
lines changed

eng/common/scripts/Create-APIReview.ps1

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
[CmdletBinding()]
22
Param (
3-
[Parameter(Mandatory=$False)]
4-
[array] $ArtifactList,
53
[Parameter(Mandatory=$True)]
6-
[string] $ArtifactPath,
4+
[array] $ArtifactList,
75
[Parameter(Mandatory=$False)]
8-
[string] $APIKey,
6+
[string] $ArtifactPath,
97
[string] $SourceBranch,
108
[string] $DefaultBranch,
119
[string] $RepoName,
@@ -97,25 +95,17 @@ function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVer
9795

9896
$uri = "${APIViewUri}/upload"
9997

100-
# Try Bearer token first, fall back to API key
98+
# Get Bearer token for authentication
10199
$bearerToken = Get-ApiViewBearerToken
102-
if ($bearerToken) {
103-
$headers = @{
104-
"Authorization" = "Bearer $bearerToken";
105-
"content-type" = "multipart/form-data"
106-
}
107-
}
108-
elseif ($APIKey) {
109-
Write-Warning "##[warning]Bearer token acquisition failed - falling back to API key."
110-
$headers = @{
111-
"ApiKey" = $APIKey;
112-
"content-type" = "multipart/form-data"
113-
}
114-
}
115-
else {
116-
Write-Error "No authentication available. Either configure AzureCLI@2 task or provide APIKey."
100+
if (-not $bearerToken) {
101+
Write-Error "Failed to acquire Bearer token for APIView authentication."
117102
return 401
118103
}
104+
105+
$headers = @{
106+
"Authorization" = "Bearer $bearerToken";
107+
"content-type" = "multipart/form-data"
108+
}
119109

120110
try
121111
{
@@ -156,23 +146,16 @@ function Upload-ReviewTokenFile($packageName, $apiLabel, $releaseStatus, $review
156146

157147
Write-Host "Request to APIView: $uri"
158148

159-
# Try Bearer token first, fall back to API key
149+
# Get Bearer token for authentication
160150
$bearerToken = Get-ApiViewBearerToken
161-
if ($bearerToken) {
162-
$headers = @{
163-
"Authorization" = "Bearer $bearerToken"
164-
}
165-
}
166-
elseif ($APIKey) {
167-
Write-Warning "##[warning]Bearer token acquisition failed - falling back to API key. Please migrate to using AzureCLI@2 task with service connection."
168-
$headers = @{
169-
"ApiKey" = $APIKey
170-
}
171-
}
172-
else {
173-
Write-Error "No authentication available. Either configure AzureCLI@2 task or provide APIKey."
151+
if (-not $bearerToken) {
152+
Write-Error "Failed to acquire Bearer token for APIView authentication."
174153
return 401
175154
}
155+
156+
$headers = @{
157+
"Authorization" = "Bearer $bearerToken"
158+
}
176159

177160
try
178161
{

0 commit comments

Comments
 (0)