0

I am developing a mobile app for moodle and I have read the documentation and several and several help links and can not definitively understand how I do the authentication in moodle via REST, I have already read several tutorials and documents but all do not show of froma Clear how this works, it fucniona. Does anyone have a light?

  • I described the basics here: https://stackoverflow.com/questions/44652206/getting-information-from-the-moodle-api-as-a-student/44692815#44692815 – FMCorz Jul 07 '17 at 09:18
  • Hello, thanks for the reply, clarified a few points. I still have a question, can I pass any user? Kind of explaining what I'm doing. I created a plugin inside moodle in moodle / local / mywwbservice, and this plugin takes information like courses and user forums logged in. I would like to know how authentic the user and within my plgin I get the data of the same without the need to ask queries in the database manually, I wanted to use a standard moodle authentication. – Thiago Cristiano Harguus Jul 07 '17 at 13:46
  • You can pass any user if the user who's associated with the token has the permissions to view the information about that other user. Try generating a token for the admin account, that should work. – FMCorz Jul 07 '17 at 14:58
  • I understand, but for each web service I can only associate a user, with this internally I can only access the value of the global variable $USER->id of the user associated with the service, wanted to access from any user I send myself, I do not know if I can Clearly what I want to do. – Thiago Cristiano Harguus Jul 07 '17 at 15:34
  • If you read the other answer, you would notice that `core_enrol_get_users_courses` accepts the `userid` as argument and thus ignores `$USER->id`. This is not the case for all web services however, they aren't very consistent so you'll have to check them individually. – FMCorz Jul 07 '17 at 15:48
  • I did so, a function that always checks the username and password user data that returns the user data. I wanted the moodle to have a function for this and that I only authenticate with a token the subsequent requests. – Thiago Cristiano Harguus Jul 07 '17 at 20:30

0 Answers0