Open
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new Poc.BackgroundWorker sample demonstrating machine-to-machine authentication for background services using OAuth2 client-credentials (Keycloak) to call the existing Weather API through YARP.
Changes:
- Introduces a .NET worker service that acquires client-credentials tokens and periodically calls
/weatherforecastvia YARP. - Adds token acquisition service code (plus an optional cached wrapper) and sample configuration.
- Adds documentation for background-service authentication and updates solution/launch configuration to include the new sample.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| samples/Poc.BackgroundWorker/appsettings.json | Adds Keycloak/YARP/worker polling configuration for the new sample. |
| samples/Poc.BackgroundWorker/appsettings.Development.json | Development logging overrides for the new worker. |
| samples/Poc.BackgroundWorker/Workers/WeatherBackgroundService.cs | Implements periodic token acquisition + API call + logging for the worker. |
| samples/Poc.BackgroundWorker/Services/ClientCredentialsTokenService.cs | Implements client-credentials token acquisition against Keycloak token endpoint. |
| samples/Poc.BackgroundWorker/Services/CachedClientCredentialsTokenService.cs | Adds an in-memory caching wrapper for tokens (currently not wired up). |
| samples/Poc.BackgroundWorker/README.md | Usage/architecture/docs for running the background worker sample. |
| samples/Poc.BackgroundWorker/Program.cs | Registers OIDC options, HttpClient, token service, and hosted worker. |
| samples/Poc.BackgroundWorker/Poc.BackgroundWorker.csproj | New worker project file and package references. |
| samples/Poc.Api/Program.cs | Minor whitespace cleanup in OIDC options configuration. |
| docs/BACKGROUND-SERVICES-AUTHENTICATION.md | New guide explaining background-service authentication and token caching. |
| AppForeach.TokenHandler.slnLaunch | Updates launch profile to start API + internal API + YARP + background worker. |
| AppForeach.TokenHandler.sln | Adds new project and docs solution items. |
samples/Poc.BackgroundWorker/Services/CachedClientCredentialsTokenService.cs
Show resolved
Hide resolved
samples/Poc.BackgroundWorker/Services/CachedClientCredentialsTokenService.cs
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.