Android app Login fails after "grant access"

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 22.2.0
Operating system and version (eg, Ubuntu 20.04): docker
Apache or nginx version (eg, Apache 2.4.25):
PHP version (eg, 7.4):

The issue you are facing:
When logging in using the Nextcloud App on Android everything works until I click “grant access”. After that I get the message: Zugriffsfehler: Operation finished with HTTP status code -1 (fail)

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

Steps to replicate it:

  1. login using the Android client
  2. grant access

The output of your Nextcloud log in Admin > Logging:

{"reqId":"v6XZaL2PSAfg6YhY3OxB","level":2,"time":"2021-11-16T19:49:26+00:00","remoteAddr":"172.22.0.1","user":"--","app":"no app in context","method":"POST","url":"/login","message":"Login failed:  (Remote IP: 172.22.0.1)","userAgent":"Xiaomi M2007J20CG (Android)","version":"22.2.0.2"}
{"reqId":"ioS2BX3G8MmRq81fVtmX","level":2,"time":"2021-11-16T19:53:32+00:00","remoteAddr":"172.22.0.1","user":"--","app":"core","method":"POST","url":"/login","message":"Login failed: 'Burger.Martina' (Remote IP: '172.22.0.1')","userAgent":"Xiaomi M2007J20CG (Android)","version":"22.2.0.2"}
{"reqId":"ioS2BX3G8MmRq81fVtmX","level":2,"time":"2021-11-16T19:53:32+00:00","remoteAddr":"172.22.0.1","user":"--","app":"no app in context","method":"POST","url":"/login","message":"Login failed: m.burger@liamix.de (Remote IP: 172.22.0.1)","userAgent":"Xiaomi M2007J20CG (Android)","version":"22.2.0.2"}

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'redis',
    'password' => '***',
    'port' => 6379,
  ),
  'passwordsalt' => '***',
  'secret' => '***',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'nextcloud.liamix.de',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '22.2.0.2',
  'overwrite.cli.url' => 'https://nextcloud.liamix.de',
  'overwriteprotocol' => 'https',
  'overwritehost' => 'nextcloud.liamix.de',
 // 'overwritecondaddr' => '192.168.10.250',
  'dbname' => 'nextcloud',
  'dbhost' => 'mysql',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => '***',
  'installed' => true,
  'instanceid' => 'oci1wwxvb0b7',
  'csrf.optout' => [
        '/^WebDAVFS/', // OS X Finder
        '/^Microsoft-WebDAV-MiniRedir/', // Windows webdav drive
        '/Nextcloud-android/',
    ],
 /* 'trusted_proxies' =>
    array (
      0 => '172.0.0.0/8',
      1 => '172.22.0.1',
    ),*/
);

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

172.22.0.3 - - [16/Nov/2021:20:15:54 +0000] "GET /login/flow/grant?clientIdentifier=&stateToken=my9BOlDtwJ5gotpdD2v6z4T73MGyRcA4HreNazoVG1Bw3FxfhwjN5NPy7SsxKfMK HTTP/1.1" 303 874 "-" "Xiaomi M2007J20CG (Android)",
172.22.0.3 - - [16/Nov/2021:20:15:54 +0000] "GET /login?redirect_url=/login/flow/grant?clientIdentifier%3D%26stateToken%3Dmy9BOlDtwJ5gotpdD2v6z4T73MGyRcA4HreNazoVG1Bw3FxfhwjN5NPy7SsxKfMK HTTP/1.1" 200 4764 "-" "Xiaomi M2007J20CG (Android)",

Login through Chrome on any system (Android, Windows, MacOS) works fine.

On the Android Nextcloud-App I get the following error: WhatsApp Image 2021-11-16 at 21.00.47

I tried working through earlier bug reports and help entries like this one: Login stalls at "grant access" with new login method on Docker installation · Issue #4786 · nextcloud/android · GitHub but that did not help. Setting the required config-settings (overwrite.cli.url) does nothing.

The setup is the following:
traefik2 (on docker) => Nextcloud