TokenPasswordExpiredException on notification dismiss

Nextcloud version (eg, 20.0.5): 28.0.2
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04
Apache or nginx version (eg, Apache 2.4.25): 2.4.52
PHP version (eg, 7.4): 8.2

The issue you are facing:

I have several unusual behaviors that may be related.

1. every time I run the cronjob, I receive a new notification that a deck card has expired. (this is a secondary problem)
2. if I want to confirm notifications using "Dismiss all notifications", I receive the error message "Failed to dismiss all notifications" in the frontend. The exception below appears in the Nextcloud log.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

1. Dismiss Notifications

The output of your Nextcloud log in Admin > Logging:

{
	"reqId": "l1RVC17fpA8xwNanGU9K",
	"level": 3,
	"time": "2024-02-13T10:00:47+00:00",
	"remoteAddr": "217.230.42.195",
	"user": "pniebeling",
	"app": "no app in context",
	"method": "DELETE",
	"url": "/ocs/v2.php/apps/notifications/api/v2/notifications",
	"message": "Exception thrown: OC\\Authentication\\Exceptions\\TokenPasswordExpiredException",
	"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
	"version": "28.0.2.5",
	"exception": {
		"Exception": "OC\\Authentication\\Exceptions\\TokenPasswordExpiredException",
		"Message": "",
		"Code": 0,
		"Trace": [
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/lib/private/Authentication/Token/Manager.php",
				"line": 154,
				"function": "getTokenById",
				"class": "OC\\Authentication\\Token\\PublicKeyTokenProvider",
				"type": "->",
				"args": [
					"*** sensitive parameters replaced ***"
				]
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/apps/notifications/lib/Push.php",
				"line": 580,
				"function": "getTokenById",
				"class": "OC\\Authentication\\Token\\Manager",
				"type": "->",
				"args": [
					"*** sensitive parameters replaced ***"
				]
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/apps/notifications/lib/Push.php",
				"line": 427,
				"function": "validateToken",
				"class": "OCA\\Notifications\\Push",
				"type": "->",
				"args": [
					"*** sensitive parameters replaced ***"
				]
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/apps/notifications/lib/Push.php",
				"line": 199,
				"function": "pushDeleteToDevice",
				"class": "OCA\\Notifications\\Push",
				"type": "->",
				"args": [
					"*** sensitive parameters replaced ***"
				]
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/apps/notifications/lib/App.php",
				"line": 99,
				"function": "flushPayloads",
				"class": "OCA\\Notifications\\Push",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/lib/private/Notification/Manager.php",
				"line": 289,
				"function": "flush",
				"class": "OCA\\Notifications\\App",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/apps/notifications/lib/Controller/EndpointController.php",
				"line": 280,
				"function": "flush",
				"class": "OC\\Notification\\Manager",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
				"line": 230,
				"function": "deleteAllNotifications",
				"class": "OCA\\Notifications\\Controller\\EndpointController",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/lib/private/AppFramework/Http/Dispatcher.php",
				"line": 137,
				"function": "executeController",
				"class": "OC\\AppFramework\\Http\\Dispatcher",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/lib/private/AppFramework/App.php",
				"line": 184,
				"function": "dispatch",
				"class": "OC\\AppFramework\\Http\\Dispatcher",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/lib/private/Route/Router.php",
				"line": 315,
				"function": "main",
				"class": "OC\\AppFramework\\App",
				"type": "::"
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/ocs/v1.php",
				"line": 65,
				"function": "match",
				"class": "OC\\Route\\Router",
				"type": "->"
			},
			{
				"file": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/ocs/v2.php",
				"line": 23,
				"args": [
					"/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/ocs/v1.php"
				],
				"function": "require_once"
			}
		],
		"File": "/var/www/vhosts/ffhstm.de/httpdocs-nextcloud/lib/private/Authentication/Token/PublicKeyTokenProvider.php",
		"Line": 216,
		"CustomMessage": "Exception thrown: OC\\Authentication\\Exceptions\\TokenPasswordExpiredException"
	}
}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

{
    "system": {
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "default_phone_region": "DE",
        "default_language": "de",
        "default_locale": "de",
        "trusted_domains": [
            "xxx.xxx.xx",
            "localhost"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "28.0.2.5",
        "overwrite.cli.url": "https:\/\/xxx.xxx.xx",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "3306",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "skeletondirectory": "",
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "htaccess.RewriteBase": "\/",
        "htaccess.IgnoreFrontController": true,
        "theme": "",
        "loglevel": 2,
        "preview_max_x": 1024,
        "preview_max_y": 1024,
        "debug": false,
        "simpleSignUpLink.shown": false,
        "user_backends": [
            {
                "class": "\\OCA\\UserExternal\\BasicAuth",
                "arguments": [
                    "https:\/\/xxx.xxx.xx\/",
                    "https:\/\/xxx.xxx.xx\/"
                ]
            }
        ],
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpauthtype": "PLAIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "maintenance": false,
        "memcache.local": "\\OC\\Memcache\\Redis",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 6379,
            "dbindex": 1
        },
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "app_install_overwrite": [
            "user_external"
        ]
    }
}