Problem Publishing first module with Publish-Module, 403 resp, invalid key

Welcome Forums General PowerShell Q&A Problem Publishing first module with Publish-Module, 403 resp, invalid key

Viewing 1 reply thread
  • Author
    Posts
    • #225591
      Participant
      Topics: 3
      Replies: 2
      Points: 22
      Rank: Member

      I’ve been using this article Publish-Module, in my first attempt in publishing to PowerShellGallery, but been getting a 403 response indicating my key may be invalid:

      Write-Error: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:10946
      Line |
      10946 | Publish-PSArtifactUtility @PublishPSArtifactUtility_Param
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      | Failed to publish module 'Krayola': 'nuget.exe failed to push 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.). '.

      The name of my module is Krayola and my username is Plastikfan. I have created my API key, which is entitled “PlastikfanKey” and is defined with a glob pattern “Plastikfan.*”. When I set up the key, I didn’t understand the full significance of the glob pattern and I have a feeling this is what’s causing the 403 response. In the edit dialog (to edit the key on PowerShellGallery), it says under Select Packages To select which packages to associate with a key, use a glob pattern, select individual packages, or both.

      So, when I publishing the module with the command:

      Publish-Module -Name Krayola -NuGetApiKey

      the name I have used doesn’t match the glob pattern defined for PlastikfanKey. Is this the reason why it fails?

      Now, the next thing I need to know, which I can’t find an answer to is how to name my module properly.

      If I want users to install my module with this command:

      Install-Module Krayola

      Does that mean that the glob pattern for PlastikfanKey should simply be ‘*’. I think it does, but I can’t be sure. On further reflection I think I would rather have my module name scoped, and I want all my modules to be consistently named.

      If I wanted the user to install the module as:

      Publish-Module -Name Plastikfan.Krayola -NuGetApiKey

      does that mean the module directory name now has to be Plastikfan.Krayola, or can it still just be Krayola. I wouldn’t want to have use the scoped name form for the directory location, because that would look odd. Does the ‘namespace’ have to be the name of the module owner or can it be something different that the owner, ie let’s say an organisation name. What are the guidelines for this?

      Normally, for these type of things I would be happy to try it out and see what happens, but I don’t want to get into the situation of having a badly published module in the gallery that I can’t remove easily. I also, can’t find enough information that describes the module name/scoping with the API key glob pattern on PowershellGallery.

       

       

      Thanks

       

       

      PS, how do you insert code snippets on this forum? If I use “Format”-> “<> Code”, it just wraps the text in the gray background as you can see I’ve done here. But when I see other articles with full blown code samples,, it looks different, ie its a properly formatted code text block, I can’t see how to do this.

       

       

       

       

       

      • This topic was modified 4 months, 2 weeks ago by Plastikfan. Reason: formatting
      • This topic was modified 4 months, 2 weeks ago by Plastikfan. Reason: remove irrelevant text (copy and paste error)
      • This topic was modified 4 months, 2 weeks ago by Plastikfan. Reason: Add question regarding the namespacing of a module
    • #227443
      Senior Moderator
      Topics: 9
      Replies: 1309
      Points: 4,783
      Helping Hand
      Rank: Community Hero

      Code formatting steps are detailed in Read Me Before Posting! You’ll be Glad You Did!

Viewing 1 reply thread
  • The topic ‘Problem Publishing first module with Publish-Module, 403 resp, invalid key’ is closed to new replies.