WCQSAuth#

class wikibaseintegrator.wbi_login.WCQSAuth(oauth_cookie)[source]#

Bases: AuthBase

Authentication for the Wikimedia Commons Query Service (WCQS, https://commons-query.wikimedia.org/), the SPARQL endpoint of Structured Data on Commons, e.g. to use the fast run mode with MediaInfo entities.

WCQS authenticates with the long-lived ‘wcqsOauth’ cookie. There is no API to get it: copy it from a web browser logged in to WCQS, see https://commons.wikimedia.org/wiki/Commons:SPARQL_query_service/API_endpoint. WCQS answers with a redirect setting a short-lived ‘wcqsSession’ cookie, which the HTTP session of WikibaseIntegrator keeps for the next queries.

To authenticate every query, including the ones of the fast run mode:

wbi_config['SPARQL_ENDPOINT_URL'] = 'https://commons-query.wikimedia.org/sparql'
wbi_config['SPARQL_AUTH'] = WCQSAuth('<wcqsOauth cookie>')

An invalid or revoked cookie raises a WCQSAuthenticationError.

Parameters:

oauth_cookie (str) – The value of the ‘wcqsOauth’ cookie, two hexadecimal strings separated by a period.