Caldav : Token is not valid: Token does not exist

Hello

Nextcloud version : 23.0.5-fpm-alpine (dockerized)
Operating system and version : Alpine 3.16
Apache or nginx version : NginX 1.22 for reverse proxy and NginX 1.22 for the web server
PHP version (eg, 7.4): replace me

The issue you are facing:
Since a re-installation of my Nextcloud, when I want to synchronize my calendar with my Android phone and caldav, I get this error : Token is not valid: Token does not exist

Thanks.

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

Steps to replicate it:

  1. Just sync my calendar with OpenSync (Android app)

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{
	"reqId": "071iUaW8VOh5JzXEl6aj",
	"level": 0,
	"time": "2022-06-19T20:51:04+00:00",
	"remoteAddr": "172.18.0.1",
	"user": "--",
	"app": "no app in context",
	"method": "PROPFIND",
	"url": "/remote.php/dav/principals/users/imbrechts.kevin/",
	"message": "Token is not valid: Token does not exist",
	"userAgent": "OpenSync/1.5.0.3-ose (2017/04/18; dav4android; okhttp3) Android/11",
	"version": "23.0.5.1",
	"exception": {
		"Exception": "OC\\Authentication\\Exceptions\\InvalidTokenException",
		"Message": "Token does not exist",
		"Code": 0,
		"Trace": [{
			"file": "/var/www/html/lib/private/Authentication/Token/Manager.php",
			"line": 150,
			"function": "getToken",
			"class": "OC\\Authentication\\Token\\DefaultTokenProvider",
			"type": "->",
			"args": ["*** sensitive parameters replaced ***"]
		}, {
			"file": "/var/www/html/lib/private/User/Session.php",
			"line": 531,
			"function": "getToken",
			"class": "OC\\Authentication\\Token\\Manager",
			"type": "->",
			"args": ["*** sensitive parameters replaced ***"]
		}, {
			"file": "/var/www/html/lib/private/User/Session.php",
			"line": 447,
			"function": "isTokenPassword",
			"class": "OC\\User\\Session",
			"type": "->",
			"args": ["*** sensitive parameters replaced ***"]
		}, {
			"file": "/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php",
			"line": 129,
			"function": "logClientIn",
			"class": "OC\\User\\Session",
			"type": "->",
			"args": ["*** sensitive parameters replaced ***"]
		}, {
			"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php",
			"line": 103,
			"function": "validateUserPass",
			"class": "OCA\\DAV\\Connector\\Sabre\\Auth",
			"type": "->",
			"args": ["*** sensitive parameters replaced ***"]
		}, {
			"file": "/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php",
			"line": 252,
			"function": "check",
			"class": "Sabre\\DAV\\Auth\\Backend\\AbstractBasic",
			"type": "->",
			"args": [{
				"__class__": "Sabre\\HTTP\\Request"
			}, {
				"__class__": "Sabre\\HTTP\\Response"
			}]
		}, {
			"file": "/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php",
			"line": 154,
			"function": "auth",
			"class": "OCA\\DAV\\Connector\\Sabre\\Auth",
			"type": "->",
			"args": [{
				"__class__": "Sabre\\HTTP\\Request"
			}, {
				"__class__": "Sabre\\HTTP\\Response"
			}]
		}, {
			"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php",
			"line": 182,
			"function": "check",
			"class": "OCA\\DAV\\Connector\\Sabre\\Auth",
			"type": "->",
			"args": [{
				"__class__": "Sabre\\HTTP\\Request"
			}, {
				"__class__": "Sabre\\HTTP\\Response"
			}]
		}, {
			"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php",
			"line": 137,
			"function": "check",
			"class": "Sabre\\DAV\\Auth\\Plugin",
			"type": "->",
			"args": [{
				"__class__": "Sabre\\HTTP\\Request"
			}, {
				"__class__": "Sabre\\HTTP\\Response"
			}]
		}, {
			"file": "/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
			"line": 89,
			"function": "beforeMethod",
			"class": "Sabre\\DAV\\Auth\\Plugin",
			"type": "->",
			"args": [{
				"__class__": "Sabre\\HTTP\\Request"
			}, {
				"__class__": "Sabre\\HTTP\\Response"
			}]
		}, {
			"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
			"line": 456,
			"function": "emit",
			"class": "Sabre\\DAV\\Server",
			"type": "->",
			"args": ["beforeMethod:PROPFIND", [{
				"__class__": "Sabre\\HTTP\\Request"
			}, {
				"__class__": "Sabre\\HTTP\\Response"
			}]]
		}, {
			"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
			"line": 253,
			"function": "invokeMethod",
			"class": "Sabre\\DAV\\Server",
			"type": "->",
			"args": [{
				"__class__": "Sabre\\HTTP\\Request"
			}, {
				"__class__": "Sabre\\HTTP\\Response"
			}]
		}, {
			"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
			"line": 321,
			"function": "start",
			"class": "Sabre\\DAV\\Server",
			"type": "->",
			"args": []
		}, {
			"file": "/var/www/html/apps/dav/lib/Server.php",
			"line": 339,
			"function": "exec",
			"class": "Sabre\\DAV\\Server",
			"type": "->",
			"args": []
		}, {
			"file": "/var/www/html/apps/dav/appinfo/v2/remote.php",
			"line": 35,
			"function": "exec",
			"class": "OCA\\DAV\\Server",
			"type": "->",
			"args": []
		}, {
			"file": "/var/www/html/remote.php",
			"line": 166,
			"args": ["/var/www/html/apps/dav/appinfo/v2/remote.php"],
			"function": "require_once"
		}],
		"File": "/var/www/html/lib/private/Authentication/Token/DefaultTokenProvider.php",
		"Line": 170,
		"Previous": {
			"Exception": "OCP\\AppFramework\\Db\\DoesNotExistException",
			"Message": "token does not exist",
			"Code": 0,
			"Trace": [{
				"file": "/var/www/html/lib/private/Authentication/Token/DefaultTokenProvider.php",
				"line": 168,
				"function": "getToken",
				"class": "OC\\Authentication\\Token\\DefaultTokenMapper",
				"type": "->",
				"args": ["*** sensitive parameters replaced ***"]
			}, {
				"file": "/var/www/html/lib/private/Authentication/Token/Manager.php",
				"line": 150,
				"function": "getToken",
				"class": "OC\\Authentication\\Token\\DefaultTokenProvider",
				"type": "->",
				"args": ["*** sensitive parameters replaced ***"]
			}, {
				"file": "/var/www/html/lib/private/User/Session.php",
				"line": 531,
				"function": "getToken",
				"class": "OC\\Authentication\\Token\\Manager",
				"type": "->",
				"args": ["*** sensitive parameters replaced ***"]
			}, {
				"file": "/var/www/html/lib/private/User/Session.php",
				"line": 447,
				"function": "isTokenPassword",
				"class": "OC\\User\\Session",
				"type": "->",
				"args": ["*** sensitive parameters replaced ***"]
			}, {
				"file": "/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php",
				"line": 129,
				"function": "logClientIn",
				"class": "OC\\User\\Session",
				"type": "->",
				"args": ["*** sensitive parameters replaced ***"]
			}, {
				"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php",
				"line": 103,
				"function": "validateUserPass",
				"class": "OCA\\DAV\\Connector\\Sabre\\Auth",
				"type": "->",
				"args": ["*** sensitive parameters replaced ***"]
			}, {
				"file": "/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php",
				"line": 252,
				"function": "check",
				"class": "Sabre\\DAV\\Auth\\Backend\\AbstractBasic",
				"type": "->",
				"args": [{
					"__class__": "Sabre\\HTTP\\Request"
				}, {
					"__class__": "Sabre\\HTTP\\Response"
				}]
			}, {
				"file": "/var/www/html/apps/dav/lib/Connector/Sabre/Auth.php",
				"line": 154,
				"function": "auth",
				"class": "OCA\\DAV\\Connector\\Sabre\\Auth",
				"type": "->",
				"args": [{
					"__class__": "Sabre\\HTTP\\Request"
				}, {
					"__class__": "Sabre\\HTTP\\Response"
				}]
			}, {
				"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php",
				"line": 182,
				"function": "check",
				"class": "OCA\\DAV\\Connector\\Sabre\\Auth",
				"type": "->",
				"args": [{
					"__class__": "Sabre\\HTTP\\Request"
				}, {
					"__class__": "Sabre\\HTTP\\Response"
				}]
			}, {
				"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php",
				"line": 137,
				"function": "check",
				"class": "Sabre\\DAV\\Auth\\Plugin",
				"type": "->",
				"args": [{
					"__class__": "Sabre\\HTTP\\Request"
				}, {
					"__class__": "Sabre\\HTTP\\Response"
				}]
			}, {
				"file": "/var/www/html/3rdparty/sabre/event/lib/WildcardEmitterTrait.php",
				"line": 89,
				"function": "beforeMethod",
				"class": "Sabre\\DAV\\Auth\\Plugin",
				"type": "->",
				"args": [{
					"__class__": "Sabre\\HTTP\\Request"
				}, {
					"__class__": "Sabre\\HTTP\\Response"
				}]
			}, {
				"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
				"line": 456,
				"function": "emit",
				"class": "Sabre\\DAV\\Server",
				"type": "->",
				"args": ["beforeMethod:PROPFIND", [{
					"__class__": "Sabre\\HTTP\\Request"
				}, {
					"__class__": "Sabre\\HTTP\\Response"
				}]]
			}, {
				"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
				"line": 253,
				"function": "invokeMethod",
				"class": "Sabre\\DAV\\Server",
				"type": "->",
				"args": [{
					"__class__": "Sabre\\HTTP\\Request"
				}, {
					"__class__": "Sabre\\HTTP\\Response"
				}]
			}, {
				"file": "/var/www/html/3rdparty/sabre/dav/lib/DAV/Server.php",
				"line": 321,
				"function": "start",
				"class": "Sabre\\DAV\\Server",
				"type": "->",
				"args": []
			}, {
				"file": "/var/www/html/apps/dav/lib/Server.php",
				"line": 339,
				"function": "exec",
				"class": "Sabre\\DAV\\Server",
				"type": "->",
				"args": []
			}, {
				"file": "/var/www/html/apps/dav/appinfo/v2/remote.php",
				"line": 35,
				"function": "exec",
				"class": "OCA\\DAV\\Server",
				"type": "->",
				"args": []
			}, {
				"file": "/var/www/html/remote.php",
				"line": 166,
				"args": ["/var/www/html/apps/dav/appinfo/v2/remote.php"],
				"function": "require_once"
			}],
			"File": "/var/www/html/lib/private/Authentication/Token/DefaultTokenMapper.php",
			"Line": 111
		},
		"CustomMessage": "Token is not valid: Token does not exist"
	}
}

OpenSync is a fork of DAVx5 and has not been updated since 2017. I would recommend using the original which is actively developed and receives regular updates…

Google Play:

F-Droid:

Thanks.
Ok but it’s not free and I need it for several phone

The F-Droid version is free.