See also the more detailed Wikimedia-specific tutorial.

MediaWiki supports OAuth v1.0a as a method of authentication. Pywikibot master also supports OAuth for MediaWiki. (Pywikibot 2.0 does not).

More information about OAuth support of MediaWiki: OAuth/For_Developers



OAuth tokens are set in authenticate of

authenticate[''] = ('consumer_token', 'consumer_secret', 'access_token', 'access_secret')

Use the site's host URL as the key of dict to specifying OAuth tokens. Also, Pywikibot supports wildcard '*' as the prefix of URL:

authenticate['*'] = ('consumer_token', 'consumer_secret', 'access_token', 'access_secret')

Pywikibot will match the best OAuth tokens for requests.

The OAuth tokens could be generated at Special:OAuthConsumerRegistration/propose. In case of a wikifarm, this needs to be the central wiki of the farm. In case of Wikimedia, it's m:Special:OAuthConsumerRegistration/propose. You need to check the option "This consumer is for use only by UserNameOfBot."

You should make unreadable for others (chmod 600 before adding OAuth tokens/secrets to it.


When there's OAuth tokens matched in, Pywikibot will disable password login automatically and use OAuth tokens for authentication instead.

NOTE: Using OAuth will block logout function.

See alsoEdit