Can't connect to server from desktop

Nextcloud version (eg, 12.0.2): 18.0.2
Operating system and version (eg, Ubuntu 17.04): Debian 10
Apache or nginx version (eg, Apache 2.4.25): 2.4.38
PHP version (eg, 7.1): 7.3.14

The issue you are facing:
Can’t connect to server from desktop app, using the version on nextcloud download page or on the latest daily build

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

Steps to replicate it:

  1. Entering the URL of server in desktop app
  2. Open the Webpage to allow App
  3. Webpage says i can close it because all is ok

The output of your Nextcloud log in Admin > Logging:

Nothing it is empty

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

$CONFIG = array (
  'instanceid' => 'XXXXXXX',
  'passwordsalt' => 'XXXXXXX/WBu',
  'secret' => 'XXXXXXX',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'cloud.XXXXXXX.com'
  ),
  'datadirectory' => '/home/XXXXX/public_html/data',
  'dbtype' => 'mysql',
  'version' => '18.0.2.2',
  'overwrite.cli.url' => 'https://cloud.XXXXX.cpù',
  'overwriteprotocol' => 'https',
  'forcessl' => true,
  'forceSSLforSubdomains' => true,
  'dbname' => 'cloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'XXXXX',
  'dbpassword' => 'XXXXXX',
  'installed' => true,
);

The output of your Apache/nginx/system log in /var/log/____:

NOTHING

But if i enable logs in Desktop app, i have strange things about a 401 error

|[OCC::OwncloudSetupWizard::slotSystemProxyLookupDone |No system proxy set by OS|
|---|---|
|[OCC::AccessManager::createRequest |2 "" "https://URL_OF_CLOUD/status.php" has X-Request-ID "XXXXXXXXX"|
|[OCC::AbstractNetworkJob::start |OCC::CheckServerJob created for "https://URL_OF_CLOUD/" + "status.php" "OCC::OwncloudSetupWizard"|
|[OCC::CheckServerJob::finished |status.php returns:  QJsonDocument({"edition":"","extendedSupport":false,"installed":true,"maintenance":false,"needsDbUpgrade":false,"productname":"Nextcloud","version":"18.0.2.2","versionstring":"18.0.2"})   QNetworkReply::NoError  Reply:  QNetworkReplyHttpImpl(0x1fbce2e17f0)|
|[OCC::DetermineAuthTypeJob::start |Determining auth type for QUrl("https://URL_OF_CLOUD/remote.php/webdav/")|
|[OCC::AccessManager::createRequest |2 "" "https://URL_OF_CLOUD/remote.php/webdav/" has X-Request-ID "XXXXXXXXX"|
|[OCC::AbstractNetworkJob::start |OCC::SimpleNetworkJob created for "https://URL_OF_CLOUD/" + "" "OCC::Account"|
|[OCC::AccessManager::createRequest |6 "PROPFIND" "https://URL_OF_CLOUD/remote.php/webdav/" has X-Request-ID "XXXXXXXXX"|
|[OCC::AbstractNetworkJob::start |OCC::SimpleNetworkJob created for "https://URL_OF_CLOUD/" + "" "OCC::Account"|
|[OCC::AccessManager::createRequest |2 "" "https://URL_OF_CLOUD/ocs/v2.php/cloud/capabilities?format=json" has X-Request-ID "XXXXXXXXX"|
|[OCC::AbstractNetworkJob::start |OCC::JsonApiJob created for "https://URL_OF_CLOUD/" + "/ocs/v2.php/cloud/capabilities" "OCC::DetermineAuthTypeJob"|
|[OCC::JsonApiJob::finished |JsonApiJob of QUrl("https://URL_OF_CLOUD/ocs/v2.php/cloud/capabilities?format=json") FINISHED WITH STATUS "OK"|
|[OCC::DetermineAuthTypeJob::checkAllDone |Auth type for QUrl("https://URL_OF_CLOUD/remote.php/webdav/") is 4|
|[OCC::AccessManager::createRequest |4 "" "https://URL_OF_CLOUD/index.php/login/v2" has X-Request-ID "XXXXXXXXX"|
|[OCC::AbstractNetworkJob::start |OCC::SimpleNetworkJob created for "https://URL_OF_CLOUD/" + "" "OCC::Account"|
|[OCC::Flow2Auth::fetchNewToken::::operator() |setting remote poll timer interval to 30000 msec|
|[OCC::AccessManager::createRequest |4 "" "https://URL_OF_CLOUD/index.php/login/v2/poll" has X-Request-ID "XXXXXXXXX"|
|[OCC::AbstractNetworkJob::start |OCC::SimpleNetworkJob created for "https://URL_OF_CLOUD/" + "" "OCC::Account"|
|[OCC::Flow2Auth::slotPollTimerTimeout::::operator() |Success getting the appPassword for user:  "jdaviaud" , server:  "https://URL_OF_CLOUD"|
|[OCC::OwncloudSetupWizard::slotConnectToOCUrl |Connect to url:  "https://URL_OF_CLOUD"|
|[OCC::WebFlowCredentials::createQNAM |Get QNAM|
|[OCC::AccessManager::createRequest |6 "PROPFIND" "https://URL_OF_CLOUD/remote.php/webdav/" has X-Request-ID "XXXXXXXXX"|
|[OCC::AbstractNetworkJob::start |OCC::PropfindJob created for "https://URL_OF_CLOUD" + "/" "OCC::OwncloudSetupWizard"|
|[OCC::WebFlowCredentials::slotFinished |request finished|
|[OCC::WebFlowCredentials::slotFinished |request finished|
|[OCC::WebFlowCredentials::stillValid |QNetworkReply::AuthenticationRequiredError|
|[OCC::WebFlowCredentials::stillValid |"L'hôte requiert une authentification"|
|[OCC::PropfindJob::finished |PROPFIND of QUrl("https://URL_OF_CLOUD/remote.php/webdav/") FINISHED WITH STATUS "AuthenticationRequiredError L'hôte requiert une authentification"|
|[OCC::PropfindJob::finished |*not* successful, http result code is 401 ""|
|[OCC::WebFlowCredentials::stillValid |QNetworkReply::AuthenticationRequiredError|
|[OCC::WebFlowCredentials::stillValid |"L'hôte requiert une authentification"|

I have an other account configured on the desktop app for an old version of nextcloud server without problem

Thanks in advance, i don’t know what to try now, i checked hundred of problems about desktop connexion but nothing similar

Trying a lot of things, i finaly found the problem from this post

adding

RewriteCond %{HTTP:Authorization} ^(.)
RewriteRule .
- [e=HTTP_AUTHORIZATION:%1]

To my vhost config