PowerShell / PowerShellGallery

219 stars 59 forks source link

The specified API key is invalid, has expired, or does not have permission to access the specified package. #277

Open chenxizhang opened 4 weeks ago

chenxizhang commented 4 weeks ago

Prerequisites

Steps to reproduce

  1. create a module
  2. obtain a apikey
  3. publish your module by using Publish-Module cmdlet or Publish-PSResource

Expected behavior

I expect the module will be published in the gallery.

Actual behavior

I got the error message below.

Error details

Publish-PSResource: Repository 'PSGallery': Response status code does not indicate success: 403 (The specified API key is invalid, has expired, or does not have permission to access the specified package.).

if I use Publish-Module, the error message should be.

Write-Error: Failed to publish module 'powershellmoduletest': 'dotnet cli failed to nuget push Pushing
powershellmoduletest.0.0.1.nupkg to 'https://www.powershellgallery.com/api/v2/package/'...   PUT
https://www.powershellgallery.com/api/v2/package/   Forbidden https://www.powershellgallery.com/api/v2/package/ 1169ms
error: Response status code does not indicate success: 403 (The specified API key is invalid, has expired, or does not
have permission to access the specified package.).   Usage: dotnet nuget push [arguments] [options]  Arguments:
[root]  Specify the path to the package and your API key to push the package to the server.  Options:   -h|--help
Show help information   --force-english-output         Forces the application to run using an invariant, English-based
culture.   -s|--source <source>           Package source (URL, UNC/folder path or package source name) to use. Defaults
to DefaultPushSource if specified in NuGet.Config.   -ss|--symbol-source <source>   Symbol server URL to use.
-t|--timeout <timeout>         Timeout for pushing to a server in seconds. Defaults to 300 seconds (5 minutes).
-k|--api-key <apiKey>          The API key for the server.   -sk|--symbol-api-key <apiKey>  The API key for the symbol
server.   -d|--disable-buffering         Disable buffering when pushing to an HTTP(S) server to decrease memory usage.
-n|--no-symbols                If a symbols package exists, it will not be pushed to a symbols server.
--no-service-endpoint          Does not append "api/v2/package" to the source URL.   --interactive
Allow the command to block and require manual action for operations like authentication.   --skip-duplicate
If a package and version already exists, skip it and continue with the next package in the push, if any.  '.

### Environment data

```PowerShell
Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

7.4.2

Visuals

image

alerickson commented 4 weeks ago

Does this issue still occur after retrieving a new API key from the Gallery? And does the scope for the key include the package you're trying to publish (or '*')?