How to use the msal.UserAgentApplication.prototype function in msal

To help you get started, we’ve selected a few msal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoftgraph / microsoft-graph-toolkit / src / providers / TeamsProvider.ts View on Github external
const provider = new MsalProvider({
      clientId: authParams.clientId,
      options: {
        auth: {
          clientId: authParams.clientId,
          redirectUri: url.protocol + '//' + url.host + url.pathname
        },
        system: {
          loadFrameTimeout: 10000
        }
      },
      scopes
    });

    if ((UserAgentApplication.prototype as any).urlContainsHash(window.location.hash)) {
      // the page should redirect again
      return;
    }

    const handleProviderState = async () => {
      // how do we handle when user can't sign in
      // change to promise and return status
      if (provider.state === ProviderState.SignedOut) {
        provider.login({
          loginHint: authParams.loginHint,
          scopes: scopes || provider.scopes
        });
      } else if (provider.state === ProviderState.SignedIn) {
        try {
          const accessToken = await provider.getAccessTokenForScopes(...provider.scopes);
          sessionStorage.removeItem(this._sessionStorageParametersKey);