ASP.NET Core Web API that combines SMHI meteorological observations with Auth0 authentication.
- Merged weather data - Combines air temperature and gust wind observations from SMHI
- Auth0 authentication - Secure API access with JWT bearer tokens
- Google sign-in - OAuth 2.0 flow via Auth0 Universal Login
- Station discovery - Browse available SMHI weather stations
- Swagger UI - Interactive API documentation with built-in authentication
- Rate limiting - Protects against abuse
- Caching - Reduces load on SMHI's public API
- .NET 10 SDK
- Auth0 account (free tier works)
- Auth0 CLI (optional):
brew install auth0
git clone https://github.com/samer-k/Lab.git
cd Lab
dotnet restore SmhiMetobs.slnxSee detailed Auth0 setup guide.
Quick version:
# Create Auth0 applications
auth0 apps create -n "SMHI MetObs" -t regular \
-c https://localhost:7195/auth/callback
# Store credentials in user-secrets
dotnet user-secrets set --project src/SmhiMetobs.Api \
"Auth0:Domain" "your-tenant.auth0.com"
dotnet user-secrets set --project src/SmhiMetobs.Api \
"Auth0:ClientId" "your-client-id"
# ... (see full guide for remaining secrets)dotnet run --project src/SmhiMetobs.Api --launch-profile httpsOpen Swagger UI: https://localhost:7195/swagger
GET /api/observations
GET /api/observations?stationId=97280&period=latest-hourAuthentication: Required (Bearer token)
Response: Merged Lufttemperatur and Byvind observations
GET /auth/access-tokenAuthentication: None
Usage: Browser-only, initiates OAuth flow
GET /api/stationsAuthentication: None
Response: List of available SMHI stations
- Implementation Details - Architecture, Auth0 setup, configuration
- Testing Guide - How to run tests, test categories, CI/CD exclusions
Run unit tests (fast, no external dependencies):
dotnet test --filter "Category!=RequiresAuth0"Run all tests (requires Auth0 setup):
dotnet testSee Testing Guide for details on test categories and why integration tests are excluded from CI/CD.
Lab/
├── src/
│ └── SmhiMetobs.Api/ # Main API project
│ ├── Endpoints/ # Minimal API endpoints
│ ├── Services/ # Business logic
│ ├── Models/ # DTOs and SMHI data models
│ ├── Authentication/ # Auth schemes and policies
│ └── README.md # Implementation details
├── tests/
│ └── SmhiMetobs.Api.Tests/ # Test suite
│ └── README.md # Testing guide
└── README.md # This file
- .NET 10 - Latest .NET framework
- ASP.NET Core Minimal APIs - Lightweight endpoint handlers
- Auth0 - Authentication and authorization
- Swashbuckle - OpenAPI/Swagger documentation
- xUnit - Testing framework
This is a personal learning project. Feel free to fork and experiment!