Skip to content
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

POC: unified OAuth flow via ActivityHandler #35

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tracyboehrer
Copy link
Member

POC for consolidating OAuth flow on the bot side... ActivityHandler. This POC subclasses ActivityHandler, and handles the state management and Activities until the user is signed in.

Compare the AuthBot to the original. This also includes the Teams and SharePoint SSO Middleware functionality so that the bot dev does not have to add that middleware to the Adapter.

Possible next steps if we want to go this direction:

  • Likely put this code in ActivityHandler
  • Use ConversationState

We could go further... Make State load/save automatic too. This avoids the bot writer from having to override OnTurnAsync and saving state. It would just happen.

Copy link
Member

@rido-min rido-min left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I like the idea of subclassing ActivityHandler for oauth, I'm wondering how to reconcile this change when using the TeamsActivityHandler.

This might be a good case to split OAuth flows, as discussed in https://github.com/microsoft/copilot-sdk-for-js/discussions/182

@@ -46,6 +48,7 @@ public CloudAdapter(
{
_activityTaskQueue = activityTaskQueue ?? throw new ArgumentNullException(nameof(activityTaskQueue));
_async = async;
_logger = logger ?? NullLogger.Instance;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line fixes a bug I'm investigating, so I think this change belongs to another PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matt has another fix related to this as well in another PR. Also, the OnTurnError is broken because for auth issues, the Body on the ErrorResponseException is null. Which just causes the original exception to be lost because of a null access.

@tracyboehrer tracyboehrer changed the title POC: OAuth flow via unified ActivityHandler POC: unified OAuth flow via ActivityHandler Jan 14, 2025
@tracyboehrer
Copy link
Member Author

tracyboehrer commented Jan 14, 2025

Although I like the idea of subclassing ActivityHandler for oauth, I'm wondering how to reconcile this change when using the TeamsActivityHandler.

This might be a good case to split OAuth flows, as discussed in microsoft/copilot-sdk-for-js#182

Me too. I'd rather have something that can be "mixed id" (so to speak). We already have a problem with ActivityHandlers because of single inheritance.

I was rather hoping this would spur discussion on how blocks of functionality (API + Activity handling) can be added to a bot.

One option would be to put this into ActivityHandler. The default behavior would be as it was before. But if the bot supplies IStorage and OAuthSettings, it would be enabled. Though I'd want to use ConversationState. This was a quick-and-dirty effort and I just used existing sample code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants