System Requirements
Before installing AuthService, ensure your system meets these requirements:Required
.NET 8 SDK
Version 8.0 or higher required for running the serviceDownload .NET 8 SDK →
Git
For cloning the repository and version controlDownload Git →
Optional
IDE
Visual Studio 2022, VS Code, or Rider recommended
API Client
Postman, Insomnia, or curl for testing endpoints
Verify Prerequisites
Check that you have the correct versions installed:Verify .NET SDK
If you see a version lower than 8.0, download and install the latest .NET 8 SDK from the official website.
Installation Steps
Restore Dependencies
The project uses NuGet packages that need to be restored:This will download:
- Microsoft.AspNetCore.Authentication.JwtBearer (8.0.0) - JWT authentication
- Microsoft.EntityFrameworkCore.Sqlite (8.0.0) - Database provider
- Microsoft.EntityFrameworkCore.Design (8.0.0) - EF Core tooling
- Swashbuckle.AspNetCore (6.5.0) - API documentation
Review Configuration (Optional)
The service comes with sensible defaults in
appsettings.json. You can review or modify:appsettings.json
The SQLite database file
authservice.db will be created automatically in the project root when you first run the service.Build the Project
Compile the application to verify everything is configured correctly:Expected output:
Verify Installation
Confirm that AuthService is running correctly:Access Swagger UI
Open your web browser and navigate to:You should see the Swagger UI interface with the following endpoints:
POST /api/auth/register- Register a new userPOST /api/auth/login- Login with credentialsPOST /api/auth/refresh- Refresh access tokenPOST /api/auth/revoke- Revoke refresh token (logout)GET /api/auth/me- Get current user info
Test the Health of the API
Make a test request to register a user:Expected Response (201 Created):If you receive this response, your installation is successful!
Project Structure
Understand how the AuthService project is organized:Configuration Options
The service can be configured throughappsettings.json:
Database Connection
- Development: Uses SQLite (file-based, no setup required)
- Production: Change to PostgreSQL, SQL Server, or MySQL connection string
JWT Configuration
| Setting | Default | Description |
|---|---|---|
SecretKey | Sample key | MUST change in production! Minimum 32 characters |
Issuer | AuthService | JWT issuer claim |
Audience | AuthService.Clients | JWT audience claim |
AccessTokenExpiryMinutes | 15 | Short-lived access token lifetime |
RefreshTokenExpiryDays | 7 | Long-lived refresh token lifetime |
Development Tools
Using Postman
A Postman collection is included in the repository:-
Import the collection:
-
Set the base URL variable:
baseUrl:http://localhost:5000
- Run requests: The collection automatically saves tokens after login/register
Using the .NET CLI
Useful commands for development:Running on a Different Port
To run the service on a different port, use the--urls argument:
appsettings.Development.json:
Troubleshooting
Port 5000 already in use
Error:
Failed to bind to address http://127.0.0.1:5000Solution:- Kill the process using port 5000:
lsof -ti:5000 | xargs kill -9(macOS/Linux) - Or run on a different port:
dotnet run --urls "http://localhost:5001"
Database locked error
Error:
SQLite Error 5: 'database is locked'Solution:- Stop all running instances of the service
- Delete
authservice.dband restart - For production, use a proper database server
JWT SecretKey error
Error:
InvalidOperationException: JWT SecretKey not configuredSolution:- Ensure
appsettings.jsonhas a validJwt:SecretKeyvalue - The key must be at least 32 characters for security
401 Unauthorized on protected endpoints
Error: Protected endpoints return 401 even with a tokenSolution:
- Verify the token format:
Authorization: Bearer {token} - Check token hasn’t expired (15-minute lifetime)
- Ensure there’s a space between “Bearer” and the token
Environment Variables
Override configuration using environment variables:Use double underscores (
__) to represent nested configuration keys in environment variables.Next Steps
Now that AuthService is installed and running:Quickstart Guide
Follow our step-by-step guide to make your first authenticated request
API Reference
Explore all available endpoints and their parameters
Authentication Flow
Understand how JWT and refresh tokens work together
Production Checklist
Prepare your service for production deployment
Development vs Production
Key differences between development and production modes:| Feature | Development | Production |
|---|---|---|
| Database | SQLite (auto-created) | PostgreSQL/SQL Server |
| Swagger UI | Enabled at root (/) | Disabled |
| HTTPS | Optional | Required |
| Secret Key | Default sample key | Secure vault (Key Vault, Secrets Manager) |
| Logging | Verbose | Warnings/Errors only |
| CORS | Permissive | Restricted to specific origins |