FEAT: Add browser-session authentication for M365 Copilot - #2514
FEAT: Add browser-session authentication for M365 Copilot#2514Adrian Gavrila (adrian-gavrila) wants to merge 4 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Behnam (behnam-o)
left a comment
There was a problem hiding this comment.
Looks good to me and works great (except the minor comment on URI, I had to change it to get it working locally.)
|
|
||
| DEFAULT_TOKEN_CAPTURE_TIMEOUT_SECONDS = 60 | ||
| DEFAULT_EXPIRY_BUFFER_SECONDS = 300 | ||
| DEFAULT_WEBSOCKET_BASE_URL = "wss://substrate.svc.cloud.microsoft/m365Copilot/Chathub" |
There was a problem hiding this comment.
I've noticed sometimes the websocket base URL ends with StreamHub , and this won't pick those up ... good idea to allow for multiple URIs here, or look for just the wss://substrate.svc.cloud.microsoft/m365Copilot part?
There was a problem hiding this comment.
oh also, this is case sensitive? I accidentally typed Streamhub and it didn't work ... do we need to be that strict?
| page = await self._ensure_browser_session_async() | ||
|
|
||
| def handle_websocket(websocket: Any) -> None: | ||
| self._handle_websocket_url( |
There was a problem hiding this comment.
nit: [discussed offline] maybe a good idea to explore: can we intercept the oauth calls and extract the auth tokens from those? that has the pro of being way more likely to still happen regardless of the websocket, even if copilot moves away from websockets, it still needs to get a token to authorize.
it looks like the copilot authenticator (username+password) does a similar thing? can they both share the same logic for extracting the token? one just drives the login automatically using username+password, and the other expects the user to login when username+password is not enough
but not a blocker at all, and just a suggestion/exploration.
Description
Adds interactive browser-session authentication for the M365 Copilot WebSocket target.
The new
BrowserSessionCopilotAuthenticator:This also updates the default M365 Copilot ChatHub endpoint to
substrate.svc.cloud.microsoftwhile leaving the separate image-upload endpoint unchanged.The M365 Copilot WebSocket protocol remains undocumented and may change.
Tests and Documentation
ty, and repository pre-commit checks pass.