11

I've created a private NuGet server (https://github.com/ai-traders/liget) which requires an API key to upload packages but not to download/restore them.

I am sure I can enhance the code of the server to mandate the use of an API Key when restoring, but the investigation I've done (mainly googling) hasn't yielded any examples of how an API Key can be specified for dotnet restore and the Visual Studio NuGet UI doesn't appear to allow it.

Is there a way of specifying an API Key for dotnet restore or is the only option to include it as a query parameter (e.g. https://mynuget.com?apikey=<API_KEY>)? Ideally I'd like to put the API Key in the header.

1 Answer 1

14

I discovered that you can't do this with an API key, but you can setup basic authentication on the NuGet server and use:

dotnet nuget add source <nuget server> --name <name> --username <user> --password <password> --store-password-in-clear-text

This also works with Visual Studio. You'll get a dialog to enter the user name and password when you configure a new NuGet server.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.