Skip to content

Copy a token from the Moodle app

Daniel Vogt edited this page Sep 16, 2021 · 9 revisions

If you are sure that the Moodle app (for Andorid or IOS) works, but none of the automatic and manual methods work to get a token, there is only one way to get a token directly from the Moodle app!

  • First you need to have Google Chrome or Chromium installed.
  • Because chromium uses a strict same-origin policy since some versions, it must be disabled. To disable this run the following command to start Chromium: chromium-browser --disable-web-security --user-data-dir="[some directory here]". Where chromium-browser can be replaced with google-chrome if this is used instead. And [some directory here] with a path to a folder e.g. ./chrome_is.
  • Open your Chrome browser and visit https://mobileapp.moodledemo.net/
  • Login to your moodle account like you did on your phone
  • Open the developer console by pressing [Control+Shift+I]
  • Go into the Network tab and reload the page with [Ctr+R]
  • Wait till the website is loaded and then scroll down the list of requests till you see requests starting with "server.php?" link in this image:

Screenshot_20200618_112144

  • Select one of these requests that starts with "server.php?". On the right side of the window you will now see a lot of information about the request.
  • Select the Headers tab and scroll down till you reach the Form Data section.
  • There you see the data that was send from the app to the server, one of the data is the wstoken, this is the token we need:

Screenshot_20200618_112714

  • Finally copy the wstoken and create a config.json file in a folder where you want to download the moodle files. In the config.json file paste the following:
{
    "token": "06eab0your_copied_token36a492",
    "moodle_domain": "moodle.ruhr-uni-bochum.de",
    "moodle_path": "/m/"
}

Replace the moodle_domain with the domain of your moodle server and the moodle_path with the installation path of the moodle (often it is just /).

Now you are ready to go! You can start the downloader in the folder where you created the config file.

Clone this wiki locally