Fetching packages works, but pushing results in access denied - nuget

I have set up a new nuget feed (company internal feed) and installing packages works without any isuues, but when I try to push a new version for a package, I get a 401 access denied.
What might be the problem?
Edit: To add some more context. I am using a MacOS machine, with a clear text password for the feed since encryption is not supported.

Solved by adding --valid-authentication-types basic in the source config.

Related

How to fix a git configuration

I tried configuring git in a Ubuntu WSL and followed instructions to configure a global credential helper by setting a certain path to it. I followed the directions verbatim but then I got a lot of errors including that the exe credential manager core does not exist and that I need to use a personal access token instead. How do I set it up to stop using the corrupted credential manager core and how do I configure a token?

How to fix 401 Unauthorized Private Github Package

I am trying to install a private Github package to a Gatsby project I'm working on that will get deployed to Netlify, but I am continuing to get a 401 Unauthorized...
When I add my token inline, or use my ~/.npmrc file it works and installs fine but doesn't work when I am using a local environment variable.
Here is my .npmrc file...
//npm.pkg.github.com/:_authToken=$NPM_TOKEN
#OWNER:registry=https://npm.pkg.github.com/OWNER
NOTE
I have also tried this with no luck -
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
#OWNER:registry=https://npm.pkg.github.com/OWNER
How do I get my environment variable to work inside my local project .npmrc file?
UPDATE
I managed to get it working locally by removing the extra the last / from github.com (shown below), but this still doesn't fix the error on the Netlify side.
- //npm.pkg.github.com/:_authToken=$NPM_TOKEN
+ //npm.pkg.github.com:_authToken=$NPM_TOKEN
Any help would be appreciated, thanks.
I got it working but I'm sure there's a better way...
The .npmrc has to be
To get it working locally -
//npm.pkg.github.com:_authToken=$READ_TOKEN
#OWNER:registry=https://npm.pkg.github.com/OWNER
However this returns a 401 unauthorised error on Netlify...
To Get it to work on Netlify -
//npm.pkg.github.com/:_authToken=${READ_TOKEN}
registry=https://npm.pkg.github.com/OWNER
However like-wise this doesn't work locally...
At the moment I'm having to switch them out manually depending on whether I'm working locally or using it in production but as I say I think there must be a better way to do that.

VSTS Extension - Token authentication error

My team and I are working on creating a VSTS extension that will work with VSTS/Azure DevOps in the cloud, but the following 500 error is being thrown when trying to do a REST request:
HostAuthorizationNotFound
Microsoft.VisualStudio.Services.DelegatedAuthorization.SessionTokenCreateException
Here's the code:
// Get an instance of the client
var client = RestClient.getClient();
client.getWorkItem(10343, ["System.Title"]).then(
function(workItem) {
console.log(JSON.stringify(workItem))
},
function () {console.log("test")}
);
Uninstalling and reinstalling the extension has no effect, which seems to be the solution for others who have encountered this problem, and the extension scope was updated to include work items.
Additionally, the personal access token generated for my account works with the VSTS CLI. I'm able to create and query for work items with no issues there.
The Microsoft documentations mentions manual token creation for programs such as C# console apps, but my impression is that this should not be needed when working with an extension.
Is there something token related that needs to be explicitly declared in code?
The solution ended up being the same as what others have posted about: uninstalling and reinstalling the extension. In this case this was something that we tried initially but did not do entirely correctly -- the reinstallation did not take full effect since all the steps weren't followed (an admin also needed to approve the republishing of the extension).
So if you get this error, rest assured that uninstalling and reinstalling should do the trick!
See the following link for more details: https://learn.microsoft.com/en-us/azure/devops/extend/get-started/node?view=vsts#install-your-extension

NuGet is returning 503 Server Unavailable

Is there a way to load a package from an alternative server when Visual Studio Package Manager (NuGet) is responding with a "The remote server returned an error: (503) Server Unavailable" message?
This is an obscure condition that will likely only occur on an "enterprisy" network environment. If these conditions apply you:
you are required to access the Internet via an HTTP proxy server
the HTTP proxy server requires a valid user ID & password (or AD authentication) to allow requests to proceed
you've been messing with cool developer tools that were ported to Windows from a Linux/Unix environment
the new cool tool(s) work after adding the HTTP_PROXY (or possibly HTTPS_PROXY or both) environment variable(s)
you can access the NuGet servers from a browser without getting a 503 error
Then it's likely you broke NuGet by inadvertently invoking this configuration feature. I'm not sure exactly how the environment variable breaks NuGet but I suspect NuGet is detecting & using the http_proxy URL but sending an empty user ID & password which causes the HTTP proxy to reject the request.
Fix: remove the environment variable(s) you added and see if the cool tool can be configured to use an HTTP proxy without them.
Update: Ran into a version of this issue with the NuGet config file referenced in the "this configuration feature" link above. Open this file:
%appdata%\nuget\nuget.config
in your favorite editor. If it contains elements with http_proxy or https_proxy then removing these elements may fix the issue too.
PS: Hopefully I'll get an up vote from Colonel Panic :-)
If you have used the package in the past it is probably in your cache. You can add the local cache as an available package source by going into the Library Package Manager Settings under the Tools menu in Visual Studio. For Visual Studio 2012, choose Tools, Library Package Manager, Package Manager Settings, and then click on Package Sources.
In the Available package sources section, type a name like "Cache" and then in for the source, browse to %LocalAppData%\NuGet\Cache. You may need to use Windows Explorer to translate %LocalAppData%\NuGet\Cache into the full path (usually C:\Users\YourAccountName\AppData\Local\NuGet\Cache).
Once you have the Cache as an available source, you can now use the Package Manager Console (found under the View menu under Other Windows or also under the Tools menu under Library Package Manager).
From the Console (which is a PowerShell window with commandlets for NuGet) you can type "get-help NuGet" to see available commands.
Then using Get-Package, you can get a list of Package ID's. Make sure the "Package source" is set to "Cache" (or whatever you called it) and the Default project is set to the project you need manipulate, both of these are dropdowns located at the top of the Page Manager Console. You can also use the Get-Project to verify you are working against the correct project in your solution.
Finally, you can type Install-Package and when prompted enter the Package ID from the output of the Get-Package commandlet.
i had also this problem, it was becouse of my network.
if you have any blocking on your Internet, (like in companies internet or etc..)
you may not allowed to download the nuget package.
try to download the package in another network, maybe it can help you!
Talbott's answer did not work for me, as my cache was empty. However, if you have used the package in another solution, you can copy the items you want from the "packages" folder in the other solution to a packages folder in your target solution.
If you have no packages installed in the target solution, you may need to add the following to a repositories.xml file in the packages folder:
<?xml version="1.0" encoding="utf-8"?>
<repositories>
</repositories>
After doing that, the packages appeared to be installed in my solution and I was able to add them to projects.
Additional Note: I had to use the "Manage NuGet Packages for Solution" option at the solution level to add the package to individual projects. Using Install-Package from the console still returns a 503 even though the packages is already installed in the solution.
You can also get this error if you are using a VPN client (e.g. Cisco AnyConnect) and you have recently renewed your VPN certificate. The issue can occur after you have updated your certificate, but before you have rebooted. A reboot resolves the issue.
It is a pretty old question, but I have just encountered the same problem. In my case it occurred because I had more than one nuget package source configured in the Visual Studio Package Manager. In my company we use NuGet to get mainstream packages and MyGet for our own stuff.
When I attempted to pull a pretty big package it failed with a 503 code and the error link looked pretty odd, it had MyGet in it istead of NuGet. Turns out Visual Studio package manager tried to pull it from another source despite having NuGet chosen as a current source. Disabling other sources and then proceeding with a download fixed it.
Hopefully it will help somebody who stumbled upon this thread just like I did.
Another possible reason for recieving 503: If you're using Azure DevOps feed, then NuGet packages are limited to 500 MB.

NuGet - Installing Individual Packages reporting "The remote server returned an error: (404) Not Found."

When using a local NuGet server, whenever I try to install an individual package from that server, all I get is this error: "The remote server returned an error: (404) Not Found."
The packages are all there in the filesystem and the feed itself sees all the packages appropriately. I can even browse the package directly!
What am I missing?
I did just upgrade from NuGet server 1.4 to 1.5, but I've seen this happen before. Touching the package files used to help, but that does not appear to be the case now.
EDIT: Actually, I hadn't seen that exact error before...I've seen this one, intermittently, that touching the package tended to fix.
On Windows Server 2008, I was having the same issue. I switched the Application Pool from "ASP.NET v4.0 Classic" to "ASP.NET v4.0". The install-package command worked fine after the change.
sigh...
http://blogs.thesitedoctor.co.uk/tim/2011/09/02/Nuget+Server+On+IIS6+Returns+404+When+Downloading+Package+After+Upgrade.aspx
EDIT: In case the link ever dies...I am hosting my NuGet server in IIS6, which wasn't set up to properly handle extensionless URLs. And since the semantics of downloading individual packages changed from a direct file link to an extensionless route, I started getting 404s. Adding the wildcard mapping described in the article fixed it instantly.
I've been trying to figure this for a couple of hours...
Checked the IIS logs and discovered that URLScan was blocking the route:
GET /Rejected-By-UrlScan ~/api/v2/package/
URLScan doesn't accept any route not starting with '/'. The best I could do was to remove the URLScan from the list of ISAPI filters for the website in the IIS Manager.
I was having the same issue on Windows Server 2008.
Problem was in my own package MyPackage.nupkg that I saved without version.
MyPackage was visible in PackageManager but it was getting 404 error on install.
Fix:
I saved it with name MyPackage.1.0.0.nupkg (1.0.0 is current version) and problem was fixed.
I had the same problem, srv 2008 R2. Changed the application pool to Integrated from Classic and all works fine now.
My problem was same as image above. I could go to the site on url
http://localhost:3407/nuget/Packages
but not
http://localhost:3407/api/v2/package/{package name}/1.0.0.0
I encountered this error while trying to download Signal-R after update Nuget, however it was just that I had not checked the "Allow Nuget to download missing packages during build" option in package manager settings. Once that was that set it all worked fine again.
It could be this as well -
You are trying to refer to a url like : http://yourdomain/application/nuget/packages
Then you should change it to :
http://yourdomain/application/nuget
This is a common mistake.