@@ -328,7 +328,7 @@ private Stream InstallVersion(
328328 return null ;
329329 }
330330
331- string containerRegistryAccessToken = GetContainerRegistryAccessToken ( needCatalogAccess : false , out errRecord ) ;
331+ string containerRegistryAccessToken = GetContainerRegistryAccessToken ( needCatalogAccess : false , isPushOperation : false , out errRecord ) ;
332332 if ( errRecord != null )
333333 {
334334 return null ;
@@ -376,7 +376,7 @@ private Stream InstallVersion(
376376 /// If no credential provided at registration then, check if the ACR endpoint can be accessed without a token. If not, try using Azure.Identity to get the az access token, then ACR refresh token and then ACR access token.
377377 /// Note: Access token can be empty if the repository is unauthenticated
378378 /// </summary>
379- internal string GetContainerRegistryAccessToken ( bool needCatalogAccess , out ErrorRecord errRecord )
379+ internal string GetContainerRegistryAccessToken ( bool needCatalogAccess , bool isPushOperation , out ErrorRecord errRecord )
380380 {
381381 _cmdletPassedIn . WriteDebug ( "In ContainerRegistryServerAPICalls::GetContainerRegistryAccessToken()" ) ;
382382 string accessToken = string . Empty ;
@@ -398,7 +398,9 @@ internal string GetContainerRegistryAccessToken(bool needCatalogAccess, out Erro
398398 }
399399 else
400400 {
401- bool isRepositoryUnauthenticated = IsContainerRegistryUnauthenticated ( Repository . Uri . ToString ( ) , needCatalogAccess , out errRecord , out accessToken ) ;
401+ bool isRepositoryUnauthenticated = isPushOperation ? false : IsContainerRegistryUnauthenticated ( Repository . Uri . ToString ( ) , needCatalogAccess , out errRecord , out accessToken ) ;
402+ _cmdletPassedIn . WriteInformation ( $ "Value of isRepositoryUnauthenticated: { isRepositoryUnauthenticated } ", new string [ ] { "PSRGContainerRegistryUnauthenticatedCheck" } ) ;
403+
402404 _cmdletPassedIn . WriteDebug ( $ "Is repository unauthenticated: { isRepositoryUnauthenticated } ") ;
403405
404406 if ( errRecord != null )
@@ -1317,7 +1319,7 @@ internal bool PushNupkgContainerRegistry(
13171319
13181320 // Get access token (includes refresh tokens)
13191321 _cmdletPassedIn . WriteVerbose ( $ "Get access token for container registry server.") ;
1320- var containerRegistryAccessToken = GetContainerRegistryAccessToken ( needCatalogAccess : false , out errRecord ) ;
1322+ var containerRegistryAccessToken = GetContainerRegistryAccessToken ( needCatalogAccess : false , isPushOperation : true , out errRecord ) ;
13211323 if ( errRecord != null )
13221324 {
13231325 return false ;
@@ -1782,7 +1784,7 @@ private Hashtable[] FindPackagesWithVersionHelper(string packageName, VersionTyp
17821784 string packageNameLowercase = packageName . ToLower ( ) ;
17831785
17841786 string packageNameForFind = PrependMARPrefix ( packageNameLowercase ) ;
1785- string containerRegistryAccessToken = GetContainerRegistryAccessToken ( needCatalogAccess : false , out errRecord ) ;
1787+ string containerRegistryAccessToken = GetContainerRegistryAccessToken ( needCatalogAccess : false , isPushOperation : false , out errRecord ) ;
17861788 if ( errRecord != null )
17871789 {
17881790 return emptyHashResponses ;
@@ -1894,7 +1896,7 @@ private FindResults FindPackages(string packageName, bool includePrerelease, out
18941896 {
18951897 _cmdletPassedIn . WriteDebug ( "In ContainerRegistryServerAPICalls::FindPackages()" ) ;
18961898 errRecord = null ;
1897- string containerRegistryAccessToken = GetContainerRegistryAccessToken ( needCatalogAccess : true , out errRecord ) ;
1899+ string containerRegistryAccessToken = GetContainerRegistryAccessToken ( needCatalogAccess : true , isPushOperation : false , out errRecord ) ;
18981900 if ( errRecord != null )
18991901 {
19001902 return emptyResponseResults ;
0 commit comments