SuLab / WikidataIntegrator

A Wikidata Python module integrating the MediaWiki API and the Wikidata SPARQL endpoint
MIT License
244 stars 46 forks source link

update a deprecated request for fetching a token #174

Closed shigapov closed 3 years ago

shigapov commented 3 years ago

The POST request for fetching a token sends a warning 'warnings': {'main': {'*': 'Subscribe to the mediawiki-api-announce mailing list at <https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce> for notice of API deprecations and breaking changes.'}, 'login': {'*': 'Fetching a token via "action=login" is deprecated. Use "action=query&meta=tokens&type=login" instead.'}}. Let's replace it with GET request to "action=query". This is in accordance with https://www.mediawiki.org/wiki/API:Login.

shigapov commented 3 years ago

Ah... the next line params.update({'lgtoken': login_token}) will not work then. params has to be redefined.

LeMyst commented 3 years ago

"clientlogin" and "login" is not the same thing. This is a breaking change in the authentication flow.

I solved the issue by spliting clientlogin and login in two different things with a parameter to WDLogin()

I'm OK with the token part.

shigapov commented 3 years ago

Right, it makes sense as there are two methods at https://www.mediawiki.org/wiki/API:Login. I talked only about https://www.mediawiki.org/wiki/API:Login#Method_1._login.

shigapov commented 3 years ago

@LeMyst, is a decision on pull request lengthy here? Shall I pull it into the WikibaseIntegrator?

LeMyst commented 3 years ago

@LeMyst, is a decision on pull request is lengthy here? Shall I pull it into the WikibaseIntegrator?

Hello @shigapov, it depends if a reviewer (usually @andrawaag ) is available.

I checked when you created this issue, but I already solved the issue in WikibaseIntegrator. I didn't backported it to WikidataIntegrator. WBI use "action: login" by default but you can use the "action: clientlogin" by setting the parameter use_clientlogin to true. But if you think WikibaseIntegrator need some changes, don't hesitate to create an issue. WikibaseIntegrator also support OAuth 2.0, the preferred method when using WIkibaseIntegrator with a bot.