Home > Software design >  Artifactory keeps asking for credentials everytime
Artifactory keeps asking for credentials everytime

Time:08-12

I am working on a project which maintains NuGet packages in Artifactory. I work on Visual Studio 2022 and every time I try to open "Manage Nuget Packages", a pop-up shows up asking me for Artifactory credentials.

Artifactory Authentication Pop-up in Visual Studio 2022

Is there a way I could save the credentials somewhere?

CodePudding user response:

I should have started my quest by visiting Microsoft's doc for Nuget. I have found the solution in this link.

According to this, we can run the following command to -

Save an API key for a given server URL into NuGet.Config so that it doesn't need to be entered for subsequent commands.


nuget setapikey <key> -Source <url> [options]

Once we run this, it will create an entry in the %appdata%\NuGet\NuGet.Config file (for Windows) and for Mac/Linux, ~/.config/NuGet/NuGet.Config or ~/.nuget/NuGet/NuGet.Config.

Or, we could create the following entry directly within the above Nuget.config file like so:


<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />
    <add key="JFrog" value="https://xyz.jfrog.io/artifactory/api/nuget/nuget-local" />
  </packageSources>
  <apikeys>
    <add key="https://xyz.jfrog.io/artifactory/api/nuget/nuget-local" value="YOUR_JFROG_API_KEY" />
  </apikeys>
</configuration>

  • Related