Jump to content

API talk:Account creation

About this board

Unrecognized parameters: mailpassword, reason, email, username, realname.

1
Seppl2013 (talkcontribs)

The above error message appears if i use the MW 1.27 API. The documentations says the change was >=1.27 but the above code worke with 1.27 and does not with 1.31.

I find the description in the order of steps confusing. The example code does not fit the description any more.

The descriptions seems to ask for getting the createtoken first then using it for the the authmanagerinfo call. In the API sandbox it works without the token see https://en.wikipedia.org/wiki/Special:ApiSandbox#action=query&format=json&meta=authmanagerinfo&amirequestsfor=create

Now I get a json result like this:

{
  "batchcomplete": "",
  "query": {
    "authmanagerinfo": {
      "canauthenticatenow": "",
      "cancreateaccounts": "",
      "preservedusername": "",
      "requests": [{
        "id": "MediaWiki\\Auth\\TemporaryPasswordAuthenticationRequest",
        "metadata": {},
        "required": "primary-required",
        "provider": "Temporary password",
        "account": "",
        "fields": {
          "mailpassword": {
            "type": "checkbox",
            "label": "Use a temporary random password and send it to the specified email address",
            "help": "Can be used to create account for another person without learning the password."
          }
        }
      }, {
        "id": "MediaWiki\\Auth\\PasswordAuthenticationRequest",
        "metadata": {},
        "required": "primary-required",
        "provider": "Password-based authentication",
        "account": "",
        "fields": {
          "username": {
            "type": "string",
            "label": "Username",
            "help": "Username for authentication."
          },
          "password": {
            "type": "password",
            "label": "Password",
            "help": "Password for authentication.",
            "sensitive": ""
          },
          "retype": {
            "type": "password",
            "label": "Retype password:",
            "help": "Password again to confirm.",
            "sensitive": ""
          }
        }
      }, {
        "id": "MediaWiki\\Auth\\UsernameAuthenticationRequest",
        "metadata": {},
        "required": "required",
        "provider": "MediaWiki\\Auth\\UsernameAuthenticationRequest",
        "account": "MediaWiki\\Auth\\UsernameAuthenticationRequest",
        "fields": {
          "username": {
            "type": "string",
            "label": "Username",
            "help": "Username for authentication."
          }
        }
      }, {
        "id": "MediaWiki\\Auth\\UserDataAuthenticationRequest",
        "metadata": {},
        "required": "required",
        "provider": "MediaWiki\\Auth\\UserDataAuthenticationRequest",
        "account": "MediaWiki\\Auth\\UserDataAuthenticationRequest",
        "fields": {
          "email": {
            "type": "string",
            "label": "Email",
            "help": "Email address",
            "optional": ""
          },
          "realname": {
            "type": "string",
            "label": "Real name",
            "help": "Real name of the user",
            "optional": ""
          }
        }
      }, {
        "id": "MediaWiki\\Auth\\CreationReasonAuthenticationRequest",
        "metadata": {},
        "required": "optional",
        "provider": "MediaWiki\\Auth\\CreationReasonAuthenticationRequest",
        "account": "MediaWiki\\Auth\\CreationReasonAuthenticationRequest",
        "fields": {
          "reason": {
            "type": "string",
            "label": "Reason",
            "help": "Message shown in the account creation log"
          }
        }
      }]
    }
  }
}

What is it good for? How is it used? What is the structure/motivation? Where is an example of using this information?

Reply to "Unrecognized parameters: mailpassword, reason, email, username, realname."
Anomie (talkcontribs)

@SSethi (WMF): I adjusted the rewrite slightly to remove confusion over different "methods". There's only one method, it's just that it can play out in different ways depending how much the client assumes about which extensions are installed. On one end the client might assume everything and never use API:Authmanagerinfo (except maybe to get the captcha data), while on the other end the client might assume nothing at all and build its UI based entirely on the data returned by API:Authmanagerinfo.

The one remaining possible issue is the header that says "MediaWiki version: ≥ 1.21", but this page documents how it works after it was completely changed in 1.27. Trying to follow the instructions here on a wiki using 1.21–1.26 will quickly fail. API:Account creation/pre-1.27, which was moved to the bottom under "See also", documents how it worked for those versions; I wonder if that should be linked more prominently somehow.

SSethi (WMF) (talkcontribs)

@Anomie Thanks for making the changes! I've tried to highlight the point you've indicated (recent edit). Also, I wanted to learn if you have a sense of how popular the use of the process documented here: https://www.mediawiki.org/w/index.php?title=API:Account_creation#Example_3:_Account_creation_on_a_wiki_with_a_CAPTCHA,_an_OpenID_extension,_and_a_two-factor_authentication_extension_enabled is? Would be useful to have a sample code that illustrates it just like we have now for a wiki with CAPTCHA enabled in Example 2?

Anomie (talkcontribs)

Thanks.

That specific process doesn't actually exist outside of the example, as far as I know. What might be useful as sample code would be something that implements the "on the other end the client might assume nothing at all and build its UI based entirely on the data returned by API:Authmanagerinfo" bit I mentioned above, although actually doing that might be more work than you want to do right now.

SSethi (WMF) (talkcontribs)

@Anomie In the sample code in Example 2, we've `create_account_with_captcha.py` where in we are fetching captcha fields from API:Authmanagerinfo. Will it be useful to expand that example to build the entire UI from the data provided by the module?

Anomie (talkcontribs)

Yes, that's what would be useful.

I leave it to you to decide whether it'd be useful enough for however much work it turns out to be.

You might look at AuthManagerSpecialPage::getAuthForm() in MediaWiki core for some inspiration. That's the method that turns the set of AuthenticationRequests into an HTMLForm for Special:UserLogin and Special:CreateAccount.

Reply to "Recent rewrite"
Planetenxin (talkcontribs)

I'd like to batch create users using this API and set each users language. How to do this? Is it possible to use API:Options for setting someone else's options?

Anomie (talkcontribs)

If you creating a user while not being logged in to your own account, the language will be set based on the language of the request. Use the uselang parameter to specify that.

If you're creating a user while being logged in to your own account, there's no way to do this in a standard MediaWiki installation. On your own wiki you could write a SecondaryAuthenticationProvider to provide an option for setting the language when creating the user.

No, it's not possible to use API:Options to set the options of a user other than the currently logged-in user.

Reply to "Set user language"

Set email in MediaWiki 1.28

3
2A06:4282:4:9800:69DD:6663:6FC3:E622 (talkcontribs)

Hi,

The "email" parameter seems to have been removed in 1.27 from the "createaccount" action. Is there any remplacement ? I cannot find a API to set it for a user ...

Best regards

Anomie (talkcontribs)
JBGO (talkcontribs)

Thanks for the quick response ! I had the parameter $wgEnableEmail set to false so it wasn't shown on my api. Thanks for the help :)

Reply to "Set email in MediaWiki 1.28"
There are no older topics