Login to Moodle app via ADB

Source: https://moodledev.io/general/app/development/link-handling/deep-linking

To facilitate easier login with bulk devices or BYOD, you can do the login into the moodle app without typing the URL, username, and password every single time.

First check if the user has the token and private token generated. If not, create them first (see the other post).

Now crosscheck the usernames and the token, export them into a textfile. In phpmyAdmin, open the moodle’s database and do the follwing:

SELECT u.id, u.username, t.token, t.privatetoken FROM `pf_user` AS u LEFT JOIN `pf_external_tokens` AS t ON u.id = t.userid WHERE u.username LIKE 'sj%' ORDER BY t.userid ASC

You will get a cross-linked table of the username, token, and external tokens.

Now connect your device, developers mode enabled and have Moodle installed, and type into terminal:

adb shell am start -a android.intent.action.VIEW -d 'moodlemobile://MOODLEURL?token=809a77df7687&privatetoken=zszP1SdXZ2D?redirect=?redirect=/course/view.php?id=XX'

This will call the URL via the default browser and trigger Moodle to go to the URL, skipping the site searching and login screen.

Leave a Reply

Your email address will not be published. Required fields are marked *