Blame SOURCES/evolution-data-server-3.12.11-caldav-password-ask-for-oauth.patch

5e6360
diff -up evolution-data-server-3.12.11/calendar/backends/caldav/e-cal-backend-caldav.c.caldav-password-ask-for-oauth evolution-data-server-3.12.11/calendar/backends/caldav/e-cal-backend-caldav.c
5e6360
--- evolution-data-server-3.12.11/calendar/backends/caldav/e-cal-backend-caldav.c.caldav-password-ask-for-oauth	2015-08-21 21:19:05.100977813 +0200
5e6360
+++ evolution-data-server-3.12.11/calendar/backends/caldav/e-cal-backend-caldav.c	2015-08-21 21:19:23.430977037 +0200
5e6360
@@ -130,6 +130,7 @@ struct _ECalBackendCalDAVPrivate {
5e6360
 	 * message than a generic 401 description. */
5e6360
 	GError *bearer_auth_error;
5e6360
 	GMutex bearer_auth_error_lock;
5e6360
+	gboolean using_bearer_auth;
5e6360
 };
5e6360
 
5e6360
 /* Forward Declarations */
5e6360
@@ -558,6 +559,7 @@ status_code_to_result (SoupMessage *mess
5e6360
                        GError **perror)
5e6360
 {
5e6360
 	ECalBackendCalDAVPrivate *priv;
5e6360
+	gchar *uri;
5e6360
 
5e6360
 	g_return_val_if_fail (cbdav != NULL, FALSE);
5e6360
 	g_return_val_if_fail (message != NULL, FALSE);
5e6360
@@ -616,14 +618,17 @@ status_code_to_result (SoupMessage *mess
5e6360
 
5e6360
 	default:
5e6360
 		d (g_debug ("CalDAV:%s: Unhandled status code %d\n", G_STRFUNC, status_code));
5e6360
+		uri = soup_uri_to_string (soup_message_get_uri (message), FALSE);
5e6360
 		g_propagate_error (
5e6360
 			perror,
5e6360
 			e_data_cal_create_error_fmt (
5e6360
 				OtherError,
5e6360
-				_("Unexpected HTTP status code %d returned (%s)"),
5e6360
+				_("Unexpected HTTP status code %d returned (%s) for URI: %s"),
5e6360
 					message->status_code,
5e6360
 					message->reason_phrase && *message->reason_phrase ? message->reason_phrase :
5e6360
-					(soup_status_get_phrase (message->status_code) ? soup_status_get_phrase (message->status_code) : _("Unknown error"))));
5e6360
+					(soup_status_get_phrase (message->status_code) ? soup_status_get_phrase (message->status_code) : _("Unknown error")),
5e6360
+					uri ? uri : "[null]"));
5e6360
+		g_free (uri);
5e6360
 		break;
5e6360
 	}
5e6360
 
5e6360
@@ -1039,12 +1044,14 @@ soup_authenticate (SoupSession *session,
5e6360
 	extension_name = E_SOURCE_EXTENSION_AUTHENTICATION;
5e6360
 	auth_extension = e_source_get_extension (source, extension_name);
5e6360
 
5e6360
+	cbdav->priv->using_bearer_auth = E_IS_SOUP_AUTH_BEARER (auth);
5e6360
+
5e6360
 	if (retrying || cbdav->priv->force_ask_password) {
5e6360
-		cbdav->priv->force_ask_password = TRUE;
5e6360
+		cbdav->priv->force_ask_password = !cbdav->priv->using_bearer_auth;
5e6360
 		return;
5e6360
 	}
5e6360
 
5e6360
-	if (E_IS_SOUP_AUTH_BEARER (auth)) {
5e6360
+	if (cbdav->priv->using_bearer_auth) {
5e6360
 		soup_authenticate_bearer (session, msg, auth, cbdav);
5e6360
 
5e6360
 	/* do not send same password twice, but keep it for later use */
5e6360
@@ -5190,7 +5197,7 @@ caldav_try_password_sync (ESourceAuthent
5e6360
 
5e6360
 	/* Busy lock is already acquired by caldav_do_open(). */
5e6360
 
5e6360
-	if (cbdav->priv->force_ask_password) {
5e6360
+	if (cbdav->priv->force_ask_password && !cbdav->priv->using_bearer_auth) {
5e6360
 		cbdav->priv->force_ask_password = FALSE;
5e6360
 		return E_SOURCE_AUTHENTICATION_REJECTED;
5e6360
 	}
5e6360
@@ -5202,7 +5209,7 @@ caldav_try_password_sync (ESourceAuthent
5e6360
 
5e6360
 	if (local_error == NULL) {
5e6360
 		result = E_SOURCE_AUTHENTICATION_ACCEPTED;
5e6360
-	} else if (g_error_matches (local_error, E_DATA_CAL_ERROR, AuthenticationFailed)) {
5e6360
+	} else if (!cbdav->priv->using_bearer_auth && g_error_matches (local_error, E_DATA_CAL_ERROR, AuthenticationFailed)) {
5e6360
 		result = E_SOURCE_AUTHENTICATION_REJECTED;
5e6360
 		g_clear_error (&local_error);
5e6360
 	} else {