Authentication
Learn how to authenticate API requests to NugetHosting.
⏱️ 4 min read
Overview
NugetHosting supports multiple authentication methods:
- Bearer Token - Recommended for API access
- Basic Authentication - For NuGet/Docker clients
- API Key Header - Legacy support
All methods require a valid API token.
Bearer Token (Recommended)
Include your token in the Authorization header:
curl -X GET "https://api.nugethosting.com/v1/packages" \
-H "Authorization: Bearer YOUR_API_TOKEN"JavaScript/TypeScript
const response = await fetch('https://api.nugethosting.com/v1/packages', {
headers: {
'Authorization': `Bearer ${API_TOKEN}`
}
});Basic Authentication
Use Basic auth for NuGet and Docker clients. The username is always api:
curl -u "api:YOUR_API_TOKEN" https://api.nugethosting.com/v1/packagesOr manually encode credentials:
# Base64 encode "api:YOUR_TOKEN"
echo -n "api:YOUR_API_TOKEN" | base64
# Use in header
curl -H "Authorization: Basic YXBpOllPVVJfQVBJX1RPS0VO" \
https://api.nugethosting.com/v1/packagesAPI Key Header
For legacy compatibility, you can use the X-NuGet-ApiKey header:
curl -H "X-NuGet-ApiKey: YOUR_API_TOKEN" \
https://api.nugethosting.com/v1/packages💡 Note: This method is primarily used by the NuGet CLI's push command.
Error Responses
Authentication failures return these HTTP status codes:
| Status | Description |
|---|---|
401 | Missing or invalid token |
403 | Token lacks required scope |
429 | Rate limit exceeded |
Example Error Response
{
"error": "unauthorized",
"message": "Invalid or expired API token",
"status": 401
}