Two factor app failing to load

Hi,

I have developed a 2FA app and it works fine on the instance I developed it. However, it fails to load on the instance I moved it to.
What could be the problem?

Here’s the log:

{"reqId":"Px2pmnAhHYZ7vZdko6lC","level":3,"time":"2022-02-09T08:15:26+00:00","remoteAddr":"193.156.42.5","user":"admin","app":"no app in context","method":"GET","url":"/ocs/v2.php/apps/notifications/api/v2/notifications","message":"Could not load two-factor auth provider OCA\\externaltwofactor\\Provider\\TotpProvider","userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.3 Safari/605.1.15","version":"23.0.1.2","exception":{"Exception":"Exception","Message":"Could not load two-factor auth provider OCA\\externaltwofactor\\Provider\\TotpProvider","Code":0,"Trace":[{"file":"/var/www/html/lib/private/Authentication/TwoFactorAuth/Manager.php","line":133,"function":"getProviders","class":"OC\\Authentication\\TwoFactorAuth\\ProviderLoader","type":"->","args":[{"__class__":"OC\\User\\User"}]},{"file":"/var/www/html/core/Middleware/TwoFactorMiddleware.php","line":125,"function":"isTwoFactorAuthenticated","class":"OC\\Authentication\\TwoFactorAuth\\Manager","type":"->","args":[{"__class__":"OC\\User\\User"}]},{"file":"/var/www/html/lib/private/AppFramework/Middleware/MiddlewareDispatcher.php","line":97,"function":"beforeController","class":"OC\\Core\\Middleware\\TwoFactorMiddleware","type":"->","args":[{"__class__":"OCA\\Notifications\\Controller\\EndpointController"},"listNotifications"]},{"file":"/var/www/html/lib/private/AppFramework/Http/Dispatcher.php","line":118,"function":"beforeController","class":"OC\\AppFramework\\Middleware\\MiddlewareDispatcher","type":"->","args":[{"__class__":"OCA\\Notifications\\Controller\\EndpointController"},"listNotifications"]},{"file":"/var/www/html/lib/private/AppFramework/App.php","line":157,"function":"dispatch","class":"OC\\AppFramework\\Http\\Dispatcher","type":"->","args":[{"__class__":"OCA\\Notifications\\Controller\\EndpointController"},"listNotifications"]},{"file":"/var/www/html/lib/private/Route/Router.php","line":302,"function":"main","class":"OC\\AppFramework\\App","type":"::","args":["OCA\\Notifications\\Controller\\EndpointController","listNotifications",{"__class__":"OC\\AppFramework\\DependencyInjection\\DIContainer"},{"apiVersion":"v2","_route":"ocs.notifications.Endpoint.listNotifications"}]},{"file":"/var/www/html/ocs/v1.php","line":62,"function":"match","class":"OC\\Route\\Router","type":"->","args":["/ocsapp/apps/notifications/api/v2/notifications"]},{"file":"/var/www/html/ocs/v2.php","line":23,"args":["/var/www/html/ocs/v1.php"],"function":"require_once"}],"File":"/var/www/html/lib/private/Authentication/TwoFactorAuth/ProviderLoader.php","Line":73,"CustomMessage":"--"}}

Sorry. I can only post the line in the code:

// Provider class can not be resolved
  			} catch (QueryException $exc) {
  				// Provider class can not be resolved
  				throw new Exception("Could not load two-factor auth provider $class");

server/lib/private/Authentication/TwoFactorAuth/ProviderLoader.php at master · nextcloud/server · GitHub

But why the same code works on another instance?

I do not know it. But somewhere in this code before:

			foreach ($providerClasses as $class) {
					try {
						$this->loadTwoFactorApp($appId);
						$provider = OC::$server->query($class);
						$providers[$provider->getId()] = $provider;

is there any dependency I must activate or something? I dunno why this provider isn’t being caught up.

Perhaps a needed app is not installed?

could you please share a link to the code? thanks

Thanks @ChristophWurst . I managed to fix it. It was - if I remember well - a mismatch between lowercase and uppercase on the namespace, or rather a mismatch between those on info.xml and on the php file.
It works now/ :slight_smile: