🌐 Documentation is currently available in English only. We're working on translations.

Home / Docs / API Reference / Authentication

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/packages

Or 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/packages

API 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:

StatusDescription
401Missing or invalid token
403Token lacks required scope
429Rate limit exceeded

Example Error Response

{
  "error": "unauthorized",
  "message": "Invalid or expired API token",
  "status": 401
}
Was this page helpful?