nopSolutions/nopCommerce · error · NopException

Facebook authentication module cannot be loaded

Error message

Facebook authentication module cannot be loaded

What it means

Thrown by FacebookAuthenticationController.Login as a NopException when _authenticationPluginManager.IsPluginActiveAsync(FacebookAuthenticationDefaults.SystemName, currentCustomer, storeId) returns false. It means the Facebook external-auth plugin is not active for the current customer/store combination.

Source

Thrown at src/Plugins/Nop.Plugin.ExternalAuth.Facebook/Controllers/FacebookAuthenticationController.cs:109

        _facebookExternalAuthSettings.ClientKeyIdentifier = model.ClientId;
        _facebookExternalAuthSettings.ClientSecret = model.ClientSecret;
        await _settingService.SaveSettingAsync(_facebookExternalAuthSettings);

        //clear Facebook authentication options cache
        _optionsCache.TryRemove(FacebookDefaults.AuthenticationScheme);

        _notificationService.SuccessNotification(await _localizationService.GetResourceAsync("Admin.Plugins.Saved"));

        return Configure();
    }

    public async Task<IActionResult> Login(string returnUrl)
    {
        var store = await _storeContext.GetCurrentStoreAsync();
        var methodIsAvailable = await _authenticationPluginManager
            .IsPluginActiveAsync(FacebookAuthenticationDefaults.SystemName, await _workContext.GetCurrentCustomerAsync(), store.Id);
        if (!methodIsAvailable)
            throw new NopException("Facebook authentication module cannot be loaded");

        if (string.IsNullOrEmpty(_facebookExternalAuthSettings.ClientKeyIdentifier) ||
            string.IsNullOrEmpty(_facebookExternalAuthSettings.ClientSecret))
            throw new NopException("Facebook authentication module not configured");

        //configure login callback action
        var authenticationProperties = new AuthenticationProperties
        {
            RedirectUri = Url.Action("LoginCallback", "FacebookAuthentication", new { returnUrl = returnUrl })
        };
        authenticationProperties.SetString(FacebookAuthenticationDefaults.ErrorCallback, Url.RouteUrl(NopRouteNames.General.LOGIN, new { returnUrl }));

        return Challenge(authenticationProperties, FacebookDefaults.AuthenticationScheme);
    }

    public async Task<IActionResult> LoginCallback(string returnUrl)
    {
        //authenticate Facebook user

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. In admin, enable the Facebook external authentication plugin for the relevant store and customer scope.
  2. Verify the customer hitting the URL belongs to a role for which the plugin is active.
  3. Ensure the login link is only rendered when the plugin is active (call IsPluginActiveAsync before showing the button).

Example fix

// before: rendering the FB login button unconditionally
// after: only show when active
@if (await _authenticationPluginManager.IsPluginActiveAsync(
        FacebookAuthenticationDefaults.SystemName, customer, store.Id))
{ <a href="@Url.Action("Login","FacebookAuthentication")">Facebook</a> }
Defensive patterns

Strategy: validation

Validate before calling

var store = await _storeContext.GetCurrentStoreAsync();
if (!await _authenticationPluginManager.IsPluginActiveAsync(FacebookAuthenticationDefaults.SystemName, await _workContext.GetCurrentCustomerAsync(), store.Id))
    // do not expose/hit the Login action; show 'auth unavailable'

Try / catch

try { return await Login(returnUrl); }
catch (NopException ex) when (ex.Message.Contains("cannot be loaded"))
{ return RedirectToRoute(Login); }

Prevention

When it happens

Trigger: A user hits the Facebook login URL but the plugin is disabled globally, disabled for the current store, or not enabled for the current customer role. The check combines system-name, customer, and store scope.

Common situations: Admin disabled the Facebook plugin or limited it to specific stores/customer roles; multi-store setup where Facebook auth is enabled only on some stores; plugin installed but not marked active.

Understand the failure class

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/be40ff9fdf41b0b8. Report an issue: GitHub.