{"record":{"id":"be40ff9fdf41b0b8","repo":"nopSolutions/nopCommerce","slug":"facebook-authentication-module-cannot-be-loaded","errorCode":null,"errorMessage":"Facebook authentication module cannot be loaded","messagePattern":"Facebook authentication module cannot be loaded","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Plugins/Nop.Plugin.ExternalAuth.Facebook/Controllers/FacebookAuthenticationController.cs","lineNumber":109,"sourceCode":"        _facebookExternalAuthSettings.ClientKeyIdentifier = model.ClientId;\n        _facebookExternalAuthSettings.ClientSecret = model.ClientSecret;\n        await _settingService.SaveSettingAsync(_facebookExternalAuthSettings);\n\n        //clear Facebook authentication options cache\n        _optionsCache.TryRemove(FacebookDefaults.AuthenticationScheme);\n\n        _notificationService.SuccessNotification(await _localizationService.GetResourceAsync(\"Admin.Plugins.Saved\"));\n\n        return Configure();\n    }\n\n    public async Task<IActionResult> Login(string returnUrl)\n    {\n        var store = await _storeContext.GetCurrentStoreAsync();\n        var methodIsAvailable = await _authenticationPluginManager\n            .IsPluginActiveAsync(FacebookAuthenticationDefaults.SystemName, await _workContext.GetCurrentCustomerAsync(), store.Id);\n        if (!methodIsAvailable)\n            throw new NopException(\"Facebook authentication module cannot be loaded\");\n\n        if (string.IsNullOrEmpty(_facebookExternalAuthSettings.ClientKeyIdentifier) ||\n            string.IsNullOrEmpty(_facebookExternalAuthSettings.ClientSecret))\n            throw new NopException(\"Facebook authentication module not configured\");\n\n        //configure login callback action\n        var authenticationProperties = new AuthenticationProperties\n        {\n            RedirectUri = Url.Action(\"LoginCallback\", \"FacebookAuthentication\", new { returnUrl = returnUrl })\n        };\n        authenticationProperties.SetString(FacebookAuthenticationDefaults.ErrorCallback, Url.RouteUrl(NopRouteNames.General.LOGIN, new { returnUrl }));\n\n        return Challenge(authenticationProperties, FacebookDefaults.AuthenticationScheme);\n    }\n\n    public async Task<IActionResult> LoginCallback(string returnUrl)\n    {\n        //authenticate Facebook user","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Plugins/Nop.Plugin.ExternalAuth.Facebook/Controllers/FacebookAuthenticationController.cs#L91-L127","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["In admin, enable the Facebook external authentication plugin for the relevant store and customer scope.","Verify the customer hitting the URL belongs to a role for which the plugin is active.","Ensure the login link is only rendered when the plugin is active (call IsPluginActiveAsync before showing the button)."],"exampleFix":"// before: rendering the FB login button unconditionally\n// after: only show when active\n@if (await _authenticationPluginManager.IsPluginActiveAsync(\n        FacebookAuthenticationDefaults.SystemName, customer, store.Id))\n{ <a href=\"@Url.Action(\"Login\",\"FacebookAuthentication\")\">Facebook</a> }","handlingStrategy":"validation","validationCode":"var store = await _storeContext.GetCurrentStoreAsync();\nif (!await _authenticationPluginManager.IsPluginActiveAsync(FacebookAuthenticationDefaults.SystemName, await _workContext.GetCurrentCustomerAsync(), store.Id))\n    // do not expose/hit the Login action; show 'auth unavailable'","typeGuard":null,"tryCatchPattern":"try { return await Login(returnUrl); }\ncatch (NopException ex) when (ex.Message.Contains(\"cannot be loaded\"))\n{ return RedirectToRoute(Login); }","preventionTips":["Only render the Facebook login button when IsPluginActiveAsync is true.","Keep plugin/store/role scoping documented in admin.","Test the login flow after enabling the plugin."],"tags":["external-auth","plugins","facebook","config","authentication"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}