General developer forum

Strange behavior generating tokens for services as admin

 
Picture of Daniel Cleto
Strange behavior generating tokens for services as admin
 

Hello,

I'm using an external webservice, when a user with a student role asks for a token it works perfect, but if that user requested a token as an admin moodle throws an error  "errorcode": "cannotcreatetoken", and says the user doesn't have permissions to create a token for that service. All this only happens if the user has never asked for a token before becoming an admin.

 
Average of ratings: -
Picture of Paul Holden
Re: Strange behavior generating tokens for services as admin
Core developersParticularly helpful MoodlersPlugin developers

Admin users can't create tokens via the web services API - they must be generated manually as documented here:

https://docs.moodle.org/34/en/Using_web_services#Create_a_token

 
Average of ratings: -
Picture of Daniel Cleto
Re: Strange behavior generating tokens for services as admin
 

Thanks Paul, "For security reason, tokens are not automatically generated in the administrator security keys page", could you explain to me how is this a security issue?, im developing an app for the admins and that was a problem.

 
Average of ratings: -