Exception in Nextcloud 23 when trying to "grant access"

Nextcloud version (eg, 20.0.5): 23.0.1.2
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04.4 LTS
Apache or nginx version (eg, Apache 2.4.25): NGINX 1.18.0
PHP version (eg, 7.4): 7.4

The issue you are facing:

When logging in from a new device, a screen appears asking to “grant access” to the device. Clicking the “grant access” button does nothing and I can see an exception being logged in nextcloud.log.

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

Steps to replicate it:

  1. Use a device you never used to login before
  2. Install and start the Nextcloud app
  3. Try to login to the Nextcloud server and try to click on the “grant access” button

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

Nothing interesting, no errors logged

Please note I am running Nextcloud in Docker. Here is the docker-compose.yaml file:

version: "3.7"

services:
  mariadb:
    image: mariadb:10.5
    init: true
    restart: unless-stopped
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    environment:
      MYSQL_ROOT_PASSWORD: xxx
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: xxx
    volumes:
      - /data/nextcloud/var-lib-mysql:/var/lib/mysql

  redis:
    image: redis
    init: true
    restart: unless-stopped

  nextcloud:
    image: nextcloud:23-apache
    init: true
    restart: unless-stopped
    environment:
      MYSQL_HOST: mariadb
      MYSQL_DATABASE: nextcloud
      MYSQL_USER: nextcloud
      MYSQL_PASSWORD: xxx
      REDIS_HOST: redis
    volumes:
      - /data/nextcloud/base:/var/www/html
      - /data/nextcloud/config:/var/www/html/config
      - /data/nextcloud/data:/var/www/html/data
      - /data/nextcloud/custom_apps:/var/www/html/custom_apps
      - /data/nextcloud/themes:/var/www/html/themes
    ports:
      - "8081:80"

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

<?php
$CONFIG = array (
  'instanceid' => 'xxx',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => 'xxx',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '23.0.1.2',
  'overwrite.cli.url' => 'https://xxx',
  'dbname' => 'nextcloud',
  'dbhost' => 'mariadb',
  'dbport' => '3306',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'xxx',
  'installed' => true,
  'maintenance' => false,
  'loglevel' => 2,
  'has_rebuilt_cache' => true,
  '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,
    ),
  ),
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'redis',
    'password' => '',
    'port' => 6379,
  ),
  'theme' => '',
);

The output of your Nextcloud log in Admin > Logging:

{
  "reqId": "9QpHvnpKgYjN7cUBsLOe",
  "level": 3,
  "time": "2022-03-04T21:02:12+00:00",
  "remoteAddr": "82.69.72.91",
  "user": "--",
  "app": "PHP",
  "method": "GET",
  "url": "/apps/accessibility/css/user-a82fd95db10ff25dfad39f07372ebe37",
  "message": "file_get_contents(/var/www/html/data/appdata_ocixfull7q7h/css/icons/icons-list.template): Failed to open stream: No such file or directory at /var/www/html/lib/private/Files/Storage/Local.php#277",
  "userAgent": "iPhone (Nextcloud iOS)",
  "version": "23.0.1.2",
  "exception": {
    "Exception": "Error",
    "Message": "file_get_contents(/var/www/html/data/appdata_ocixfull7q7h/css/icons/icons-list.template): Failed to open stream: No such file or directory at /var/www/html/lib/private/Files/Storage/Local.php#277",
    "Code": 0,
    "Trace": [
      {
        "function": "onError",
        "class": "OC\\Log\\ErrorHandler",
        "type": "::",
        "args": [
          2,
          "file_get_contents(/var/www/html/data/appdata_ocixfull7q7h/css/icons/icons-list.template): Failed to open stream: No such file or directory",
          "/var/www/html/lib/private/Files/Storage/Local.php",
          277
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Storage/Local.php",
        "line": 277,
        "function": "file_get_contents",
        "args": [
          "/var/www/html/data/appdata_ocixfull7q7h/css/icons/icons-list.template"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Storage/Wrapper/Wrapper.php",
        "line": 247,
        "function": "file_get_contents",
        "class": "OC\\Files\\Storage\\Local",
        "type": "->",
        "args": [
          "appdata_ocixfull7q7h/css/icons/icons-list.template"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/View.php",
        "line": 1171,
        "function": "file_get_contents",
        "class": "OC\\Files\\Storage\\Wrapper\\Wrapper",
        "type": "->",
        "args": [
          "appdata_ocixfull7q7h/css/icons/icons-list.template"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/View.php",
        "line": 601,
        "function": "basicOperation",
        "class": "OC\\Files\\View",
        "type": "->",
        "args": [
          "file_get_contents",
          "/appdata_ocixfull7q7h/css/icons/icons-list.template",
          [
            "read"
          ]
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/Node/File.php",
        "line": 56,
        "function": "file_get_contents",
        "class": "OC\\Files\\View",
        "type": "->",
        "args": [
          "/appdata_ocixfull7q7h/css/icons/icons-list.template"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Files/SimpleFS/SimpleFile.php",
        "line": 90,
        "function": "getContent",
        "class": "OC\\Files\\Node\\File",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/apps/accessibility/lib/Controller/AccessibilityController.php",
        "line": 164,
        "function": "getContent",
        "class": "OC\\Files\\SimpleFS\\SimpleFile",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 217,
        "function": "getCss",
        "class": "OCA\\Accessibility\\Controller\\AccessibilityController",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 126,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          {
            "__class__": "OCA\\Accessibility\\Controller\\AccessibilityController"
          },
          "getCss"
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/App.php",
        "line": 157,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          {
            "__class__": "OCA\\Accessibility\\Controller\\AccessibilityController"
          },
          "getCss"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Route/Router.php",
        "line": 302,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\Accessibility\\Controller\\AccessibilityController",
          "getCss",
          {
            "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
          },
          {
            "md5": "a82fd95db10ff25dfad39f07372ebe37",
            "_route": "accessibility.accessibility.getCss"
          }
        ]
      },
      {
        "file": "/var/www/html/lib/base.php",
        "line": 1006,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "/apps/accessibility/css/user-a82fd95db10ff25dfad39f07372ebe37"
        ]
      },
      {
        "file": "/var/www/html/index.php",
        "line": 36,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/html/lib/private/Log/ErrorHandler.php",
    "Line": 92,
    "CustomMessage": "--"
  }
}
{
  "reqId": "9QpHvnpKgYjN7cUBsLOe",
  "level": 3,
  "time": "2022-03-04T21:02:12+00:00",
  "remoteAddr": "82.69.72.91",
  "user": "--",
  "app": "index",
  "method": "GET",
  "url": "/apps/accessibility/css/user-a82fd95db10ff25dfad39f07372ebe37",
  "message": "File does not exist",
  "userAgent": "iPhone (Nextcloud iOS)",
  "version": "23.0.1.2",
  "exception": {
    "Exception": "OCP\\Files\\NotFoundException",
    "Message": "File does not exist",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/html/lib/private/Files/SimpleFS/SimpleFile.php",
        "line": 93,
        "function": "checkFile",
        "class": "OC\\Files\\SimpleFS\\SimpleFile",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/apps/accessibility/lib/Controller/AccessibilityController.php",
        "line": 164,
        "function": "getContent",
        "class": "OC\\Files\\SimpleFS\\SimpleFile",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 217,
        "function": "getCss",
        "class": "OCA\\Accessibility\\Controller\\AccessibilityController",
        "type": "->",
        "args": []
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/Http/Dispatcher.php",
        "line": 126,
        "function": "executeController",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          {
            "__class__": "OCA\\Accessibility\\Controller\\AccessibilityController"
          },
          "getCss"
        ]
      },
      {
        "file": "/var/www/html/lib/private/AppFramework/App.php",
        "line": 157,
        "function": "dispatch",
        "class": "OC\\AppFramework\\Http\\Dispatcher",
        "type": "->",
        "args": [
          {
            "__class__": "OCA\\Accessibility\\Controller\\AccessibilityController"
          },
          "getCss"
        ]
      },
      {
        "file": "/var/www/html/lib/private/Route/Router.php",
        "line": 302,
        "function": "main",
        "class": "OC\\AppFramework\\App",
        "type": "::",
        "args": [
          "OCA\\Accessibility\\Controller\\AccessibilityController",
          "getCss",
          {
            "__class__": "OC\\AppFramework\\DependencyInjection\\DIContainer"
          },
          {
            "md5": "a82fd95db10ff25dfad39f07372ebe37",
            "_route": "accessibility.accessibility.getCss"
          }
        ]
      },
      {
        "file": "/var/www/html/lib/base.php",
        "line": 1006,
        "function": "match",
        "class": "OC\\Route\\Router",
        "type": "->",
        "args": [
          "/apps/accessibility/css/user-a82fd95db10ff25dfad39f07372ebe37"
        ]
      },
      {
        "file": "/var/www/html/index.php",
        "line": 36,
        "function": "handleRequest",
        "class": "OC",
        "type": "::",
        "args": []
      }
    ],
    "File": "/var/www/html/lib/private/Files/SimpleFS/SimpleFile.php",
    "Line": 138,
    "CustomMessage": "--"
  }
}

Normally that is used to authenticate a specific client. E.g. you use the desktop client, then you get a login window, you login and then grant access for the desktop client. Then, an app password is created for this client. The same for mobile clients. However, it shouldn’t appear when you simply access via browser.

The desktop or mobile client should keep this app-password to login all the time (until you revoke the app password via user-interface or you remove the account). I am not sure for the mobile clients, how it deals with multiple accounts if you have to switch accounts that make it reauthenticate.

Hi @tflidd ,

Yes, that’s using the Nextcloud app on an iPhone. The trace seems to imply that the code fails to open a certain file and then crashes because of that…

Any idea about what is going on and how I can fix the problem?

Do you use a specific theme? The web-interface is working without errors?

Hi @tflidd ,

No, I never changed the theme. The web interface is working fine.

Cheers

I found a very old bug:

and one still open bug regarding videos:

Other clients are working (desktop/android)?

I don’t think these bugs are related. My bug is related to a file that looks like it is part of the Nextcloud installation itself:
/var/www/html/data/appdata_ocixfull7q7h/css/icons/icons-list.template

I have Nextcloud installed on my Android device. When I tried to enable 2FA, I tried to reconfigure DAVx5 to sync the contacts and it was showing the same problem: The “grant access” screen would show up, but nothing would happen when I click on it. I didn’t check the Nextcloud logs at that time, however…

You can scan the appdata folders as well, perhaps that helps if there is some old stuff:
https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html#scan-appdata

For the 2FA, I’d try to generate manually app passwords. You can use them to login to your account with a specific application. It’s just to check if there is an issue with that function as well. You can e.g. use a webdav client (winscp) to log in to your account. Probably you can use your mobile app as well (however, the automatic procedure should work).

Hi @tflidd ,

OK, thanks for the suggestions. I tried to run occ, but there is no sudo in the container:

OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "sudo": executable file not found in $PATH: unknown

I don’t really care about 2FA at this moment, I just gave you another example to say that exactly the same problem happens on Android under certain circumstances.

What is the root cause of my problem?

Perhaps without sudo and it’s running already with the right user? I don’t know the containers at all. I moved your topic to the section for docker. There should be people to help you out much better.

Hi @tflidd ,

OK, I have been able to run the file scan command like so:

# docker-compose exec -u 33 nextcloud php occ files:scan-app-data
Scanning AppData for files

+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 15802   | 5010  | 00:00:27     |
+---------+-------+--------------+

It doesn’t look like anything was wrong? What does this output mean?

Thanks a lot!

It just reports how many files were found. And if there were old linked files or something that don’t exist any more that should be repaired. But I suppose that didn’t solve your problem?

Hi @tflidd ,

That didn’t solve the problem, but Nextcloud does not log a trace now. I think I mistakenly associated the trace with the problem, but it looks like it’s purely a client-side bug…