'JFROG basic Authentication for Artifactory from powershell throwing 403

I am trying to authenticate to JFROG from powershell i tried it with my token and its giving 403 forbidden

  PS C:\Myproject> $myHeaders = @{'X-JFrog-Art-Api' = 'AKCp8sdFTEKF1Y5MDgM3M8RK6bRkKWoX43jWranZvS2U2DE82KFE7243F'}

  PS C:\Myproject> Invoke-WebRequest -Uri "https://org.jfrog.io/" -Method Get -Headers $myHeaders

    Invoke-WebRequest : 403 Forbidden
    nginx
   At line:1 char:1
    + Invoke-WebRequest -Uri "https://fiprod.jfrog.io/" -Method Get -Header ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand

Any idea on how to authenticate to JFROG artifactory via TOken using Powershell



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source