MSAL issue with Copilot Studio SDK

Ouverte
#527 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
55/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Calme
Stack technique
react, typescript

Piste de recherche

Commencez par localiser l’initialisation de MSAL et les appels à loginPopup dans le webpart, puis examinez l’impact du rendu de React sur l’instance MSAL. Vérifiez qu’une seule instance est réutilisée et que handleRedirectPromise() est appelé. Le travail est terminé lorsque l’authentification renvoie le jeton au webpart et que la popup SharePoint redirigée se ferme automatiquement.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Issue Description:
We developed a webpart to access copilot agent data. When configuring the webpart on a SharePoint site, it opens a popup for authentication. After authentication succeeds, the token is not being returned to the webpart.

Microsoft Support team findings below,

The Auth pop-up opening the Sharepoint site is a direct symptom of new MSAL instance created on every call combined with missing handleRedirectPromise().
Here's what's happening step by step:

  1. loginPopup() opens a popup to login.microsoftonline.com.
  2. User picks their account → Azure AD authenticates successfully
  3. Azure AD redirects the popup to the redirect Uri, which is settings. redirectUri || window.location.origin — i.e., the SharePoint site URL
  4. The popup now loads the full SharePoint site instead of closing
    The popup should close automatically at this point. MSAL's popup flow works by having the parent window monitor the popup's URL via polling. When the popup redirects back to the same origin with the auth code in the URL hash, the parent MSAL instance reads the code, processes it, and closes the popup.
    But because a new MSAL instance is created on every call and handleRedirectPromise() is never called:
    • The MSAL instance that opened the popup may have been garbage collected (React re-render)
    • The polling interval that monitors the popup URL is gone
    • Nobody reads the auth code from the popup's URL
    • Nobody closes the popup
    • The popup just sits there showing the SharePoint site it was redirected to
    So the SharePoint site loading in the popup is the redirect working correctly from Azure AD's side — but MSAL on the parent side failing to intercept and close it.

To fix this, the MSAL instance must be a singleton, and handleRedirectPromise() must be called.

Langage dominant
TypeScript
Étoiles
807
Forks
494
Merge moyen
2 j 3 h
PR mergées (30 j)
1

Préparer son environnement

Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de microsoft/CopilotStudioSamples

Toutes les issues de microsoft/CopilotStudioSamples

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.