-
Notifications
You must be signed in to change notification settings - Fork 8
Add support for bearer token - semantic kernel sample #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@Josina20 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds support for bearer token authentication as an alternative to the existing authentication handler in the Semantic Kernel sample agent. The change allows the agent to bypass the standard "MyAuth" sign-in handler when a bearer token is provided via environment variable, enabling scenarios where token-based authentication is preferred over interactive authentication flows.
Key changes:
- Adds
BEARER_TOKENenvironment variable configuration for development - Conditionally disables auto-signin handlers when bearer token is present
- Passes bearer token to tool service for authentication when USE_AGENTIC_AUTH is false
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
dotnet/semantic-kernel/sample-agent/Properties/launchSettings.json |
Adds BEARER_TOKEN environment variable configuration for development launch settings |
dotnet/semantic-kernel/sample-agent/Agents/MyAgent.cs |
Implements conditional logic to skip auto-signin handlers when bearer token is configured, and adds new InstallationUpdate route registration |
dotnet/semantic-kernel/sample-agent/Agents/Agent365Agent.cs |
Adds bearer token retrieval and conditional passing to tool service based on authentication mode |
dotnet/semantic-kernel/sample-agent/Properties/launchSettings.json
Outdated
Show resolved
Hide resolved
| TermsAndConditionsAccepted = true; | ||
|
|
||
| bool useBearerToken = !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("BEARER_TOKEN")); | ||
| string[] autoSignInHandlersForNotAgenticAuth = useBearerToken ? [] : new[] { MyAuthHanlder }; |
Copilot
AI
Dec 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable name 'MyAuthHanlder' has a typo - it should be 'MyAuthHandler' (with 'Handler' spelled correctly). This typo appears to be pre-existing but is now being used in the new conditional logic. Consider fixing this typo throughout the codebase for consistency.
No description provided.