Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nuget.exe push/delete won't use API Key #2627

Closed
spadapet opened this issue Apr 20, 2016 · 9 comments
Closed

nuget.exe push/delete won't use API Key #2627

spadapet opened this issue Apr 20, 2016 · 9 comments

Comments

@spadapet
Copy link

spadapet commented Apr 20, 2016

Using version 3.4.3.854

REPRO

  • Start with the default nuget.config file in %appdata%\nuget that only has nuget.org as a source
  • In a browser, log into your nuget.org account and follow the instructions to set an apikey:
  • nuget.exe setApiKey XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
  • Try to unlist one of your packages:
  • Example 1: nuget.exe delete foo 99.99 -Source nuget.org
  • Example 2: nuget.exe push foo.nupkg -Source nuget.org

RESULT
WARNING: No API Key was provided and no API Key could be found for 'https://www.nuget.org/api/v2/package'. To save an API Key for a source use the 'setApiKey' command.

EXPECT
I already did set the API Key according to the instructions. Unlisting works fine if I set the API Key for https://www.nuget.org/api/v2/package, but why do I need to do that?

NOTE
Same issue with myget.org

@yishaigalatzer
Copy link

@spadapet is this a regression?

@spadapet
Copy link
Author

I tried the previous version (3.3.0.212) and it fails for an even more bizarre reason:

> nuget3.exe delete MyTestPackageX 2.0.2 -Source nuget.org
WARNING: No API Key was provided and no API Key could be found for 'https://api.nuget.org/v3/index.json'. To save an API Key for a source use the 'setApiKey' command.
Deleting MyTestPackageX 2.0.2 from the 'https://api.nuget.org/v3/index.json'.
Failed to process request. 'HTTP Version Not Supported'.
The remote server returned an error: (505) Http Version Not Supported..

Looks like this:

image

And then if I add the API Key for https://api.nuget.org/v3/index.json, it still fails:

image

So, the behavior is sort of better now since I can actually unlist. But I need to know to set the API Key for a specific packages URL

@spadapet
Copy link
Author

spadapet commented Apr 21, 2016

Ah, it is a regression from nuget.exe 2.8.60717.93.

  • nuget2.exe setApiKey [my key]
  • nuget2.exe delete mytestpackagex 2.0.2

Works fine

image

@spadapet spadapet changed the title nuget.exe delete won't use API Key for nuget.org nuget.exe push/delete won't use API Key for nuget.org May 12, 2016
@zhili1208
Copy link
Contributor

the issue here is
nuget.exe setApiKey [mykey]
the default apikey config is key ="https://www.nuget.org", value =[mykey]
nuget.exe delete mytestpackagex 2.0.2
nuget try to find value of key "https://www.nuget.org/api/v2/package" in nuget.config, it return null.

@jmyersmsft
Copy link

Whether or not this is the same root cause as #2975 , that bug is not just a problem of inconsistent defaults, and it's not just a problem for nuget.org.

@zhili1208
Copy link
Contributor

@jmyersmsft yes, this is not a problem for nuget.org, it's for all sources

@zhili1208 zhili1208 changed the title nuget.exe push/delete won't use API Key for nuget.org nuget.exe push/delete won't use API Key Jun 14, 2016
@rrelyea rrelyea modified the milestones: 3.5 Beta3, 3.5 RC Jun 14, 2016
@rrelyea
Copy link
Contributor

rrelyea commented Jun 14, 2016

Zhi found several dupes. Putting in beta3 for analysis.

@wallism
Copy link

wallism commented Jan 27, 2017

I had the same issue today on v3.4.3.855.
I set the api key using the required command, then when I ran the push I got this warning:

WARNING: No API Key was provided and no API Key could be found for 'https://www.nuget.org/api/v2/package'

and was asked to login using username and password.

So the issue for me was, when I ran: nuget SetApiKey abc...def, I noticed that in the config file ("%Appdata%\Roaming\Nuget\NuGet.Config") it added a key for https://www.nuget.org, when I changed to to the full path it worked fine -> https://www.nuget.org/api/v2/package

So the bug appears to be in the SetApiKey command, not setting the correct key (for the push case anyway)

@emgarten
Copy link
Member

@wallism get the latest nuget.exe 3.5.0 here: http://dist.nuget.org/index.html

If you are still seeing the bug open a new issue to track this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants