PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
489 stars 94 forks source link

Unable to load service index for v3 nuget feeds when passing credentials #101

Closed MaxFrost closed 1 year ago

MaxFrost commented 4 years ago
$Cred = Get-Credential $Username
Register-PSResourceRepository -Name $AuthenticatedFeed -URL "https://pkgs.dev.azure.com/<teamname>/_packaging/<feedname>/nuget/v3/index.json" -Trusted

Find-PSResource -Repository $AuthenticatedFeed -Credential $Cred
Find-PSResource: Unable to load the service index for source https://pkgs.dev.azure.com/<teamname>/_packaging/<feedname>/nuget/v3/index.json.

If I register the same feed with v2, https://pkgs.dev.azure.com/<teamname>/_packaging/<feedname>/nuget/v2, I can use the same Find-PSResource call passing in $cred and it functions

Using Powershell 7.0.0, PowerShellGet 3.0.0-beta1 $Cred is using a PAT token with full access to remove any doubt if it's an issue on the authentication side as the password.

dbrennand commented 2 years ago

Hi @alerickson,

Was there a fix implemented for this issue? I can't seem to find the PR that referenced a fix for this? 😞

I've been experiencing this exact error with GitLab v3 Nuget feed: https://docs.gitlab.com/ee/user/packages/nuget_repository/

Further details in https://github.com/PowerShell/PowerShellGet/issues/215#issuecomment-1227266276

Steps to Reproduce

Create deploy token (username: build-deploy-token) with read_package_registry, write_package_registry permissions.

# Enter build-deploy-token as username and token secret as password
$Creds = Get-Credential
Register-PSResourceRepository -Name "GitLab" -Uri "https://gitlab.<domain>.com/api/v4/projects/<id>/packages/nuget/index.json" -Trusted -Verbose
# Name doesn't matter as it fails to load service index
Find-PSResource -Name "Test" -Repository "GitLab" -Credential $Creds -Verbose

# Output:
# PS > Find-PSResource -Repository "GitLab" -Credential $Creds -Verbose -Name test
# VERBOSE: Searching in repository GitLab
# VERBOSE: credential successfully set for repository: GitLab
# VERBOSE: Error retrieving resource from repository: Unable to load the service index for source https://gitlab.<domain>.com/api/v4/projects/<id>/packages/nuget/index.json.
mimetnet commented 2 years ago

@alerickson - can this please be reopened? The above example is still reproducing the problem.