> On Thu, Dec 22, 2016 at 4:33 PM, Scott Koranda <skora...@gmail.com> wrote: > BTW, I updated https://www.mediawiki.org/wiki/API:Account_creation for > MediaWiki 1.27 and later. >
Thank you. That is quite helpful. I appreciate your time. I am now able to provision new accounts in the way that I need to in order to support my use case. I did notice that new documentation does not call out that one may need to send the password (and retype) in the POST body rather than in the query string. Is that an oversight? If so, may I edit the page and add that level of detail? (I appear to have the necessary editing rights but since I am new to the community I am unclear on the style and level of detail you want to maintain). For the archives, here is some example working code. Again, I am using the MediaWiki OAuth extension with an "Owner-only" consumer for authentication for this client: $consumerKey = 'ffffd455ba9fb5fe8ad152e71045f3e8'; $consumerSecret = 'ffff674c4e75a8ba6bfcc77c564e81e929199e'; $accessToken = 'ffff6e60f77c7ad9dcfd11fd996b86'; $accessSecret = 'ffff70c9a21c6a1609a1c3715014012be56e292'; $base = "https://myserver/w/api.php"; $oauth = new OAuth( $consumerKey, $consumerSecret, OAUTH_SIG_METHOD_HMACSHA1,OAUTH_AUTH_TYPE_AUTHORIZATION ); $oauth->setToken( $accessToken, $accessSecret ); $queryData = array(); $queryData['action'] = 'query'; $queryData['meta'] = 'tokens'; $queryData['type'] = 'createaccount'; $queryData['format'] = 'json'; $url = $base . "?" . http_build_query($queryData); $oauth->fetch($url, null, OAUTH_HTTP_METHOD_POST); $response = json_decode($oauth->getLastResponse(), true); $createAccountToken = $response['query']['tokens']['createaccounttoken']; $parameters = array(); $parameters['createtoken'] = $createAccountToken; $parameters['password'] = "CsmfeVCSaKK4gzOUYgpD"; $parameters['retype'] = $parameters['password']; $queryData = array(); $queryData['action'] = 'createaccount'; $queryData['format'] = 'json'; $queryData['createreturnurl'] = "https://myserver.com"; $queryData['username'] = "Foo Bar"; $queryData['email'] = "foobar@some.domain"; $queryData['realname'] = "Ms Foo Bar"; $queryData['reason'] = "provisioning"; $url = $base . "?" . http_build_query($queryData); $oauth->fetch($url, $parameters, OAUTH_HTTP_METHOD_POST); $response = $oauth->getLastResponse(); This returns {"createaccount":{"status":"PASS","username":"Foo Bar"}} Thanks, Scott K _______________________________________________ Mediawiki-api mailing list Mediawiki-api@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-api