Thanks for your response.
Im making an app that uses moodle, not as a plugin, but as a stand-alone app. I want to read some data (courses, activities, etc.) from moodle, but i have problems using the web service.
The teachers have the capabilities for generate token and call the function core_course_get_courses. I can generate a token but when i tried to call the web service it returns webservice_access_exception. I checked the teacher capabilites and the teachers has the core_course_get_courses capabilities.
I prefer to use the web service because i want to use the moodle role to access to resource, but this problems limits me.
Using web services is the correct approach for this. In fact, this is exactly how the official Moodle app works. If you haven't already it's worth taking a look and seeing if that suits your needs.
It looks like webservice_access_exception is thrown in lots of different cases. If you can include the error message it returns, it might help someone identify your problem.