''dotnet restore' is failing when mixing a private NuGet feed with public one

I have project using packages from both private feed with authentication (jfrog based) and public one.

Restoring packages from IDE like Rider or VS is working fine, however when I am using console it is failing with 401 authorization error.

Any idea how can I fix it?

My global nuget.config file:

<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="jfrog-based-nuget" value="https://myprivate.jfrog.io/artifactory/api/nuget/v3/myprivate-nuget" />
  </packageSources>
</configuration>

Example error:

error : Failed to retrieve information about '<private-package-name>' from remote source '<private-feed>/FindPackagesById()?id='<package-name>'&semVerLevel=2.0.0'. [<solution-path>]
error : Response status code does not indicate success: 401 (Unauthorized). [<solution-path>]


Sources

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

Source: Stack Overflow

Solution Source