$createAccountToken = $response['query']['tokens']['createaccounttoken'];


I receive

{"error":{"code":"createnotoken","info":"The token parameter must be set","*":"See https://myserver/w/api.php for API usage"}}

Second question: What am I doing wrong when invoking the createaccount action?

Two things:

1. The parameter is named "createtoken", not "token".
2. You're not urlencoding it.

Thank you.

I am now sending this:

$createAccountToken = $response['query']['tokens']['createaccounttoken'];

$createAccountTokenEncoded = urlencode($createAccountToken);


But I see this error:

{"error":{"code":"createmustpostparams","info":"The following parameters were found in the query string, but must be in the POST body: createtoken","*":"See https://myserver/w/api.php for API usage"}}

I then try

$parameters = array('createtoken', $createAccountTokenEncoded);

$oauth->fetch("https://myserver/w/api.php?action=createaccount&format=json&name=FooBar&email=foobar@gmail.com&realname=FooBar&mailpassword=false&reason=provisioning&language=en", $parameters, OAUTH_HTTP_METHOD_POST);

but I see this error:

{"error":{"code":"createnotoken","info":"The token parameter must be set","*":"See https://myserver/w/api.php for API usage"}}


Should the createtoken be passed as part of the query string or in the POST body?

 
I am following documentation at


but it is not clear to me which parts of that page may be deprecated and precisely how I should provision a new account.

I should update that page for AuthManager. In the mean time, account creation in 1.27 and later works much like action=clientlogin, as documented at https://www.mediawiki.org/wiki/API:Login#The_clientlogin_action. See also https://www.mediawiki.org/w/api.php?modules=createaccount for the auto-generated documentation.

Thanks. I confess, however, that I am having difficulty understanding the auto-generated documentation. 

If you have time and could point me to the source code for the createaccount action I will examine it and see if I can discern what I should be passing in.

Thanks,

Scott K