endlessm / endless-key-app

Endless Key app for Windows (formerly known as kolibri-app)
https://www.endlessos.org/key
MIT License
2 stars 1 forks source link

Cannot download new content by clicking the download button in Windows app #128

Closed vanessa-chang closed 1 year ago

vanessa-chang commented 1 year ago

In andriod app, the new feature of downloading the new content within a channel is working by clicking the download (cloud) button. However, it does not work in the Windows app. It will show a warning logo. S__62529539

Test version: 6.15.0.0 Log: kolibri.txt

wjt commented 1 year ago

@starnight Do you recall if there is a way to access the web developer console in the Windows app? I wonder if there would be more useful information logged there.

Searching the kolibri.txt log for the string WARNING or for HTTP error codes:

wjt@camille:~$ grep -E '(^WARNING| [45][0-9]{2} )' Downloads/kolibri' (2).txt'
WARNING 2023-06-19 00:17:21,393 kolibri.core.device.utils Unable to remove provisioning file C:\Program Files\WindowsApps\EndlessOSFoundation.EndlessKey_6.15.0.0_x64__bt8q3zn5k2ahy\resources\app\src\automatic_provision.json after successful provisioning
WARNING 2023-06-19 00:18:00,790 kolibri_explore_plugin.collectionviews Manifest entry for 914fee213ee146de869016c287116b23 has a different version (17) than the installed channel (18)
WARNING 2023-06-19 00:18:00,806 kolibri_explore_plugin.collectionviews Manifest entry for f1ada7abc4194ff48a958337a31972c7 has a different version (4) than the installed channel (5)
INFO 2023-06-19 00:52:42,317 cherrypy.access 127.0.0.1 - - "GET /en/explore/null" 404 0 "http://localhost:5000/en/explore/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) kolibri-electron/1.0.0 Chrome/108.0.5359.215 Electron/22.3.7 Safari/537.36"
WARNING 2023-06-19 00:52:42,318 django.request Not Found: /en/explore/null
INFO 2023-06-19 00:54:08,855 cherrypy.access 127.0.0.1 - - "GET /en/explore/null" 404 0 "http://localhost:5000/en/explore/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) kolibri-electron/1.0.0 Chrome/108.0.5359.215 Electron/22.3.7 Safari/537.36"
WARNING 2023-06-19 00:54:08,856 django.request Not Found: /en/explore/null
INFO 2023-06-19 01:05:11,233 cherrypy.access 127.0.0.1 - - "GET /en/explore/app/6.15.0/virtual-field-trips/metadata.json" 404 0 "http://localhost:5000/en/explore/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) kolibri-electron/1.0.0 Chrome/108.0.5359.215 Electron/22.3.7 Safari/537.36"
WARNING 2023-06-19 01:05:11,233 django.request Not Found: /en/explore/app/6.15.0/virtual-field-trips/metadata.json
INFO 2023-06-19 16:09:45,683 cherrypy.access 127.0.0.1 - - "GET /en/explore/null" 404 0 "http://localhost:5000/en/explore/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) kolibri-electron/1.0.0 Chrome/108.0.5359.215 Electron/22.3.7 Safari/537.36"
WARNING 2023-06-19 16:09:45,684 django.request Not Found: /en/explore/null
INFO 2023-06-19 16:09:53,634 cherrypy.access 127.0.0.1 - - "GET /en/explore/app/6.15.0/virtual-field-trips/metadata.json" 404 0 "http://localhost:5000/en/explore/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) kolibri-electron/1.0.0 Chrome/108.0.5359.215 Electron/22.3.7 Safari/537.36"
WARNING 2023-06-19 16:09:53,636 django.request Not Found: /en/explore/app/6.15.0/virtual-field-trips/metadata.json
INFO 2023-06-19 16:10:08,697 cherrypy.access 127.0.0.1 - - "GET /en/explore/app/6.15.0/novels/metadata.json" 404 0 "http://localhost:5000/en/explore/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) kolibri-electron/1.0.0 Chrome/108.0.5359.215 Electron/22.3.7 Safari/537.36"
WARNING 2023-06-19 16:10:08,699 django.request Not Found: /en/explore/app/6.15.0/novels/metadata.json
INFO 2023-06-19 16:10:19,747 cherrypy.access 127.0.0.1 - - "GET /en/explore/app/6.15.0/49ers-edu-digital-playbook/metadata.json" 404 0 "http://localhost:5000/en/explore/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) kolibri-electron/1.0.0 Chrome/108.0.5359.215 Electron/22.3.7 Safari/537.36"
WARNING 2023-06-19 16:10:19,749 django.request Not Found: /en/explore/app/6.15.0/49ers-edu-digital-playbook/metadata.json
INFO 2023-06-19 16:12:58,130 cherrypy.access 127.0.0.1 - - "GET /en/explore/null" 404 0 "http://localhost:5000/en/explore/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) kolibri-electron/1.0.0 Chrome/108.0.5359.215 Electron/22.3.7 Safari/537.36"
WARNING 2023-06-19 16:12:58,131 django.request Not Found: /en/explore/null
INFO 2023-06-19 16:22:00,847 cherrypy.access 127.0.0.1 - - "GET /en/explore/null" 404 0 "http://localhost:5000/en/explore/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) kolibri-electron/1.0.0 Chrome/108.0.5359.215 Electron/22.3.7 Safari/537.36"
WARNING 2023-06-19 16:22:00,848 django.request Not Found: /en/explore/null
INFO 2023-06-19 16:22:10,168 cherrypy.access 127.0.0.1 - - "GET /en/explore/app/6.15.0/49ers-edu-digital-playbook/metadata.json" 404 0 "http://localhost:5000/en/explore/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) kolibri-electron/1.0.0 Chrome/108.0.5359.215 Electron/22.3.7 Safari/537.36"
WARNING 2023-06-19 16:22:10,169 django.request Not Found: /en/explore/app/6.15.0/49ers-edu-digital-playbook/metadata.json

It looks to me like the latter error is most likely the cause, or shares a cause, with this issue, since if I recognise the screenshot correctly @vanessa-chang is trying to download a resource from the 49ers channel.

@vanessa-chang does it work for any other channels?

vanessa-chang commented 1 year ago

@wjt No, it doesn't work for the other channel either.

note we have a blocker now (#627) so this issue cannot be tested or reproduced using the alpha flight version from the store.

starnight commented 1 year ago

@starnight Do you recall if there is a way to access the web developer console in the Windows app? I wonder if there would be more useful information logged there.

The simplest way:

  1. Run Endless Key app (Windows) => kolibri server runs
  2. Open browser with http://localhost:5000/ Then, use the browser's developer tool :)
wjt commented 1 year ago

Thanks. The developer console shows:

POST http://localhost:5000/api/tasks/tasks/ 403 (Forbidden)

The payload of the request is (typing it out, it's on another computer):

{
  channel_id: "...",
  channel_name: "foo",
  node_ids: ["..."],
  type: "kolibri.core.content.tasks.remotecontentimport"
}

and the response is:

[{"id":"PERMISSION_DENIED","metadata":{"view":"Tasks List"}}]
wjt commented 1 year ago

Comparing the Chrome OS case (works) and the Windows case (doesn't) and viewing the device page, we can see that in the Chrome OS case, the user is logged in as kolibri, but in the Windows case, the user is not logged into Kolibri. So that is presumably the cause of the 403 forbidden on Windows.

wjt commented 1 year ago

kolibri.txt kolibri-app.txt

wjt commented 1 year ago

I can't see any reference in these logs to the middleware in use. On Slack, @manuq said:

I thought [the problem would be that the Windows app doesn't do automatic provisioning and login], but I see automatic provision code in Windows and the AlwaysAuthenticatedMiddleware too in src/kolibri_tools/endless_key_settings.py

How could I investigate further?

wjt commented 1 year ago

https://github.com/endlessm/endless-key-app/blob/master/kolibri-electron/src/index.js#L76-L87 deals with trying to set KOLIBRI_AUTOMATIC_PROVISION_FILE in the environment

wjt commented 1 year ago
INFO 2023-06-21 15:03:52,636 kolibri.core.device.utils Superuser created with username 'admin' in facility 'Endless'.
WARNING 2023-06-21 15:03:52,690 kolibri.core.device.utils Unable to remove provisioning file C:\Program Files\WindowsApps\EndlessOSFoundation.EndlessKey_6.17.3.0_x64__bt8q3zn5k2ahy\resources\app\src\automatic_provision.json after successful provisioning

OK – this WARNING is expected, the file is part of the read-only app bundle.

wjt commented 1 year ago

For posterity, the error:

Screenshot 2023-06-21 152424

It is interesting (to me) that the 403 Forbidden error does not show up in Kolibri's logs at all.

manuq commented 1 year ago

Since now I have a way to reproduce the Forbidden error (by logging out) I see that these are debug level logs:

[python-devserver] DEBUG    2023-06-21 20:55:04,815 127.0.0.1 - - "POST /api/tasks/tasks/" 403 0 "http://localhost:8000/en/explore/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"

However endless-key-app is setting debug False directly in code https://github.com/endlessm/endless-key-app/blob/0d79e9bafb7539e9d27c6be9ad396c22b5629a4d/src/kolibri_tools/utils.py#L65

wjt commented 1 year ago

I am working on this on https://github.com/endlessm/endless-key-app/tree/actually-use-AlwaysAuthenticatedMiddleware by the way