I ran in the same question.
How I understand it, to get a token, you have to call the (e.g. Shibboleth) unprotected https://www.yourmoodle.com/login/token.php?username=USERNAME&password=PASSWORD&service=SERVICESHORTNAME
However, the official moodle app first opens the login page of (in our case Shibboleth) and then gets the token. What is still don't get is how the username and password are automatically inserted.
Here are resources that I found and might help you;