How to use the msal.UserAgentApplication 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 dotnet / aspnetcore / src / Components / WebAssembly / Authentication.Msal / src / Interop / AuthenticationService.ts View on Github external
constructor(private readonly _settings: AuthorizeServiceConfiguration) {

        // It is important that we capture the callback-url here as msal will remove the auth parameters
        // from the url as soon as it gets initialized.
        const callbackUrl = location.href;
        this._msalApplication = new Msal.UserAgentApplication(this._settings);

        // This promise will only resolve in callback-paths, which is where we check it.
        this._callbackPromise = this.createCallbackResult(callbackUrl);
    }
github Azure / azure-sdk-for-js / sdk / identity / identity / src / credentials / interactiveBrowserCredential.browser.ts View on Github external
}

    this.msalConfig = {
      auth: {
        clientId: options.clientId!, // we just initialized it above
        authority: `${options.authorityHost}/${options.tenantId}`,
        ...(options.redirectUri && { redirectUri: options.redirectUri }),
        ...(options.postLogoutRedirectUri && { redirectUri: options.postLogoutRedirectUri })
      },
      cache: {
        cacheLocation: "localStorage",
        storeAuthStateInCookie: true
      }
    };

    this.msalObject = new msal.UserAgentApplication(this.msalConfig);
  }
github Azure-Samples / Serverless-microservices-reference-architecture / web / serverless-microservices-web / src / utils / Authentication.js View on Github external
constructor() {
    // The window values below should by set by public/js/settings.js
    this._scopes = window.authScopes;
    this._clientId = window.authClientId;
    this._authority = window.authAuthority;

    var cb = this._tokenCallback.bind(this);
    var opts = {
      validateAuthority: false
    };
    this._userAgentApplication = new UserAgentApplication(
      this._clientId,
      this._authority,
      cb,
      opts
    );
  }
github AzureAD / microsoft-authentication-library-for-js / lib / msal-angularjs / lib / msal-angular.js View on Github external
this.init = function (configOptions, httpProvider) {
                if (configOptions) {
                    _config = configOptions;
                    if (!configOptions.optionalParams) {
                        configOptions.optionalParams = {};
                    }

                    configOptions.optionalParams.isAngular = true;

                    if (httpProvider && httpProvider.interceptors) {
                        httpProvider.interceptors.push('ProtectedResourceInterceptor');
                    }

                    // create instance with given config
                    _msal = new Msal.UserAgentApplication(configOptions.clientID, configOptions.authority, configOptions.tokenReceivedCallback, configOptions.optionalParams);
                    if (configOptions.routeProtectionConfig) {
                        _msal.routeProtectionConfig = configOptions.routeProtectionConfig;
                    }
                    else {
                        _msal.routeProtectionConfig = {};
                    }

                    _msal.loginScopes = [_msal.clientId];
                    _constants = Msal.Constants;

                } else {
                    throw new Error('You must set configOptions, when calling init');
                }
                // loginResource is used to set authenticated status
                updateDataFromCache(_msal.loginScopes);
            };
github microsoftgraph / microsoft-graph-toolkit / src / auth / V2Provider.ts View on Github external
constructor(clientId: string, scopes: string[] = ["user.read"], authority: string = null, options: any = null) {
        this.type = ProviderType.V2;
        this.provider = new UserAgentApplication(clientId, authority, this.tokenReceivedCallback);
        this.scopes = scopes;
    }
github Gimly / simpleAngularAzureB2C / src / app / authentication.service.ts View on Github external
constructor() {
    this.clientApplication =
      new Msal.UserAgentApplication(
        environment.clientID,
        this.authority,
        this.authCallback);
  }
github microsoftgraph / microsoft-graph-toolkit / src / providers / MsalProvider.ts View on Github external
if (config.clientId) {
      const msalConfig: Configuration = config.options || { auth: { clientId: config.clientId } };

      msalConfig.auth.clientId = config.clientId;
      msalConfig.cache = msalConfig.cache || {};
      msalConfig.cache.cacheLocation = msalConfig.cache.cacheLocation || 'localStorage';
      msalConfig.cache.storeAuthStateInCookie = msalConfig.cache.storeAuthStateInCookie || true;

      if (config.authority) {
        msalConfig.auth.authority = config.authority;
      }

      this.clientId = config.clientId;

      this._userAgentApplication = new UserAgentApplication(msalConfig);
      this._userAgentApplication.handleRedirectCallback(tokenReceivedCallbackFunction, errorReceivedCallbackFunction);
    } else {
      throw new Error('clientId must be provided');
    }

    this.graph = new Graph(this);

    this.trySilentSignIn();
  }
github microsoftgraph / msgraph-sdk-javascript / lib / src / MSALAuthenticationProvider.js View on Github external
function MSALAuthenticationProvider(clientId, scopes, options) {
        var callback = function (errorDesc, token, error, tokenType) {
        };
        var self = this;
        self.clientId = clientId;
        self.scopes = scopes;
        self.userAgentApplication = new msal_1.UserAgentApplication(self.clientId, undefined, callback, options);
    }
    /**