Advertisement

Unable to get moodle tokens ("errorcode": "invalidlogin")

 

I'll tell you a case where I couldn't get moodle token when using api

http://localhost/login/token.php?service=moodle_mobile_app&username=admin&password=Moodle123#

Why did it happen ?. That's because the system cannot accept the # (hashtag) character from the GET method. It needs to be changed to urlencode first before it is read by the system, because the get method is completely in the url, the # (hashtag) character in the url is %23. You can search for it on google urlencode online or you can make it yourself with php like this :

<?php
echo urlencode('Moodle123#');

?> 
If you use an input form like in HTML then you use the get method, then this is not needed because the system will automatically change the characters to urlencode. This happens only if you do it directly in your browser.

Post a Comment

0 Comments