How to access the token after user creation.

How to access the token after user creation.

by john felix -
Number of replies: 3

Hi,

 I am able to create the user and login using the moodle api. But after user creation, I am not able to see the external token. Only when I login through moodle website and click on "Security Keys", token is getting created. But I am accessing the moodle through an external site, so is there a way that I could create a token through moodle api?

Thanks

Average of ratings: -
In reply to john felix

Re: How to access the token after user creation.

by Jérôme Mouneyrac -

Hi John,

at the moment this feature only exists in 2.2 with a condition.

In 2.2 you can generate and retrieve user tokens with login/token.php => http://docs.moodle.org/dev/Creating_a_web_service_client#How_to_get_a_user_token

The condition being that the service need a shortname. At the moment a service can have a shortname if you:
* create the service as a built-in service (in db/services.php files)
* add the shortname manually in the DB. Note: we'll add the admin UI for shortname later (MDL-30229

Just for the info, the file login/token.php exists since 2.1 but can only generate token for the mobile service.

Cheers,

Jerome

In reply to Jérôme Mouneyrac

Re: How to access the token after user creation.

by john felix -

Hi Jerome,

  Thank you very much for your answer. I downloaded and installed the moodle 2.2 beta, When I completed the settings and tried to do role assignment, I got the following error. I believe it is a code error.

 

"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<EXCEPTION class=\"coding_exception\">\n<MESSAGE>Coding error detected, it must be fixed by a programmer: PHP catchable fatal error</MESSAGE>\n<DEBUGINFO>Argument 1 passed to external_api::clean_returnvalue() must be an instance of external_description, null given, called in /Applications/MAMP/htdocs/moodle22/webservice/rest/locallib.php on line 88 and defined</DEBUGINFO>\n</EXCEPTION>\n"

 

I tried to assign a student role(5) to the user at the system level(1). I have changed the student role to a system level role already.

Thanks

Average of ratings: Useful (1)
In reply to john felix

Re: How to access the token after user creation.

by Jérôme Mouneyrac -

Hi John,

can you write a detailled tracker issue about that. I'll have a look. A coding exception into a web service is a bug.

Thanks,
Jerome