This guide covers the most common authentication, session, and test setup
problems when working with py-moodle.
- Verify
MOODLE_URL,MOODLE_USERNAME, andMOODLE_PASSWORD. - Confirm the Moodle site accepts direct login for that account.
- If the site uses CAS or another single sign-on flow, enable the matching CLI settings before retrying.
- Confirm the user can open the Moodle dashboard in a browser after logging in.
- Enable the Moodle mobile web service, or provide a pre-configured token when the site blocks automatic token creation.
- If the site uses CAS, confirm the session is returning to Moodle correctly after authentication.
- Use a user that can access the Moodle mobile web service.
- Provide a pre-configured token through configuration when the site does not allow token discovery.
- Prefer session-based helpers that accept a
sesskeywhen a webservice token is not available.
- Open the Moodle dashboard manually and confirm it loads after login.
- Check whether the site immediately redirects back to the login page or an SSO prompt.
- Review reverse-proxy or CAS configuration if authenticated sessions are not preserved.
- Re-authenticate so the session can refresh its
sesskey. - Use a Moodle account with permission to access the Moodle mobile web service if you need the REST listing path.
Tests outside tests/unit/ are marked as integration tests and are skipped
unless you pass --integration.
pytest --integration --moodle-env local -m integration -n autoAdd the required environment variables for the selected target to .env:
MOODLE_<ENV>_URLMOODLE_<ENV>_USERNAMEMOODLE_<ENV>_PASSWORD
For example, the local target uses MOODLE_LOCAL_URL,
MOODLE_LOCAL_USERNAME, and MOODLE_LOCAL_PASSWORD.
Start the local stack before retrying:
make updor:
docker compose up -d