+ if (SynchronizeFolderOperation.EVENT_SINGLE_FOLDER_CONTENTS_SYNCED.
+ equals(event) &&
+ /// TODO refactor and make common
+ synchResult != null && !synchResult.isSuccess() &&
+ (synchResult.getCode() == ResultCode.UNAUTHORIZED ||
+ synchResult.isIdPRedirection() ||
+ (synchResult.isException() && synchResult.getException()
+ instanceof AuthenticatorException))) {
+
+
+ OwnCloudClient client = OwnCloudClientMap.removeClientFor(getAccount());
+ if (client != null) {
+ Credentials cred = client.getCredentials();
+ String ssoSessionCookie = client.getSsoSessionCookie();
+ if (cred != null || ssoSessionCookie != null) {
+ boolean bearerAuthorization = (cred != null && cred instanceof BearerCredentials);
+ boolean samlBasedSsoAuthorization = (cred == null && ssoSessionCookie != null);
+ AccountManager am = AccountManager.get(context);
+
+ if (bearerAuthorization) {
+ am.invalidateAuthToken(getAccount().type,
+ ((BearerCredentials)cred).getAccessToken());
+
+ } else if (samlBasedSsoAuthorization ) {
+ am.invalidateAuthToken(getAccount().type, ssoSessionCookie);
+
+ } else {
+ am.clearPassword(getAccount());
+ }
+ }
+ }
+
+ requestCredentialsUpdate();
+