Refactor SetupCommand to use GraphTokenScopeException#36
Merged
sellakumaran merged 1 commit intomainfrom Nov 20, 2025
Merged
Conversation
- Added `GraphApiService` as a dependency in `SetupCommand` and replaced inline instantiations with dependency injection. - Introduced `GraphTokenScopeException` to handle disallowed high-privilege scopes in Graph tokens. - Implemented `ValidateGraphToken` in `A365SetupRunner` to enforce least-privilege principles during token validation. - Refactored `GetTokenFromGraphClient` to use `Azure.Identity` for token retrieval and validation. - Added new error code `HighPrivilegeScopeDetected` to `ErrorCodes` for better error categorization. - Updated `Program.cs` to inject `GraphApiService` at runtime. - Enhanced unit tests to mock `GraphApiService` and ensure coverage of new functionality. - Removed redundant code and improved exception handling to exclude `Agent365Exception` from generic catch blocks. - Performed general code cleanup and added licensing information to new files.
mengyimicro
approved these changes
Nov 20, 2025
sellakumaran
added a commit
that referenced
this pull request
Feb 27, 2026
- Added `GraphApiService` as a dependency in `SetupCommand` and replaced inline instantiations with dependency injection. - Introduced `GraphTokenScopeException` to handle disallowed high-privilege scopes in Graph tokens. - Implemented `ValidateGraphToken` in `A365SetupRunner` to enforce least-privilege principles during token validation. - Refactored `GetTokenFromGraphClient` to use `Azure.Identity` for token retrieval and validation. - Added new error code `HighPrivilegeScopeDetected` to `ErrorCodes` for better error categorization. - Updated `Program.cs` to inject `GraphApiService` at runtime. - Enhanced unit tests to mock `GraphApiService` and ensure coverage of new functionality. - Removed redundant code and improved exception handling to exclude `Agent365Exception` from generic catch blocks. - Performed general code cleanup and added licensing information to new files.
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.
GraphApiServiceas a dependency inSetupCommandand replaced inline instantiations with dependency injection.GraphTokenScopeExceptionto handle disallowed high-privilege scopes in Graph tokens.ValidateGraphTokeninA365SetupRunnerto enforce least-privilege principles during token validation.GetTokenFromGraphClientto useAzure.Identityfor token retrieval and validation.HighPrivilegeScopeDetectedtoErrorCodesfor better error categorization.Program.csto injectGraphApiServiceat runtime.GraphApiServiceand ensure coverage of new functionality.Agent365Exceptionfrom generic catch blocks.