I am trying to figure out a solution on how to login into Moodle from an external API service. I have web services enabled on Moodle. My application uses a API build with Laravel which contains a method to login in directly to Moodle from another webpage. Right now I am able to get the token using GuzzleHTTP POST request like below:
$tokenBody = [
'username' => $userNameString,
'password' => $userNamePassString,
'service' => 'moodle_mobile_app'
];
$getToken = json_decode($callFedAuth->PostApi(env('TOKEN_URL'), $tokenBody));
Here I am able to get a token and private token like below:
{
"token": "59a30c31b009e8330f175e7c308c8e25"
"privatetoken": "4iFZzVhhEZF2blYZXLOhLAr2uEjka8kuHxD9lQd9EQpwFEsNZiyoVcpTPwlfNF2j"
}
Now how can I use this token to redirect from my API or navigate to the users Moodle home page directly? I can make a post request to Moodle login page, but that will only dump the html content back to me and not redirect.