wikibaseintegrator.wbi_login
Login class for Wikidata. Takes authentication parameters and stores the session cookies and edit tokens.
- class wikibaseintegrator.wbi_login.Clientlogin(user=None, password=None, mediawiki_api_url=None, token_renew_period=1800, user_agent=None)[source]
Bases:
_Login
- Parameters:
user (str | None)
password (str | None)
mediawiki_api_url (str | None)
token_renew_period (int)
user_agent (str | None)
- __init__(user=None, password=None, mediawiki_api_url=None, token_renew_period=1800, user_agent=None)[source]
This class is used to log in with a user account
- Parameters:
user (
Optional
[str
]) – The usernamepassword (
Optional
[str
]) – The passwordmediawiki_api_url (
Optional
[str
]) – The URL to the MediaWiki API (default Wikidata)token_renew_period (
int
) – Seconds after which a new token should be requested from the Wikidata serveruser_agent (
Optional
[str
]) – UA string to use for API requests.
- generate_edit_credentials()
Request an edit token and update the cookie_jar in order to add the session cookie
- Return type:
RequestsCookieJar
- Returns:
Returns a json with all relevant cookies, aka cookie jar
- get_edit_cookie()
Can be called in order to retrieve the cookies from an instance of wbi_login.Login
- Return type:
RequestsCookieJar
- Returns:
Returns a json with all relevant cookies, aka cookie jar
- get_edit_token()
Can be called in order to retrieve the edit token from an instance of wbi_login.Login
- Return type:
Optional
[str
]- Returns:
returns the edit token
- get_session()
Returns the requests.Session object used for the login.
- Return type:
Session
- Returns:
Object of type requests.Session()
- class wikibaseintegrator.wbi_login.Login(user=None, password=None, mediawiki_api_url=None, token_renew_period=1800, user_agent=None)[source]
Bases:
_Login
- Parameters:
user (str | None)
password (str | None)
mediawiki_api_url (str | None)
token_renew_period (int)
user_agent (str | None)
- __init__(user=None, password=None, mediawiki_api_url=None, token_renew_period=1800, user_agent=None)[source]
This class is used to log in with a bot password
- Parameters:
user (
Optional
[str
]) – The user of the bot password (format <User>@<BotUser>)password (
Optional
[str
]) – The password generated byt the MediaWikimediawiki_api_url (
Optional
[str
]) – The URL to the MediaWiki API (default Wikidata)token_renew_period (
int
) – Seconds after which a new token should be requested from the Wikidata serveruser_agent (
Optional
[str
]) – UA string to use for API requests.
- generate_edit_credentials()
Request an edit token and update the cookie_jar in order to add the session cookie
- Return type:
RequestsCookieJar
- Returns:
Returns a json with all relevant cookies, aka cookie jar
- get_edit_cookie()
Can be called in order to retrieve the cookies from an instance of wbi_login.Login
- Return type:
RequestsCookieJar
- Returns:
Returns a json with all relevant cookies, aka cookie jar
- get_edit_token()
Can be called in order to retrieve the edit token from an instance of wbi_login.Login
- Return type:
Optional
[str
]- Returns:
returns the edit token
- get_session()
Returns the requests.Session object used for the login.
- Return type:
Session
- Returns:
Object of type requests.Session()
- exception wikibaseintegrator.wbi_login.LoginError[source]
Bases:
Exception
Raised when there is an issue with the login
- __init__(*args, **kwargs)
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class wikibaseintegrator.wbi_login.OAuth1(consumer_token=None, consumer_secret=None, access_token=None, access_secret=None, callback_url='oob', mediawiki_api_url=None, mediawiki_index_url=None, token_renew_period=1800, user_agent=None)[source]
Bases:
_Login
- Parameters:
consumer_token (str | None)
consumer_secret (str | None)
access_token (str | None)
access_secret (str | None)
callback_url (str)
mediawiki_api_url (str | None)
mediawiki_index_url (str | None)
token_renew_period (int)
user_agent (str | None)
- __init__(consumer_token=None, consumer_secret=None, access_token=None, access_secret=None, callback_url='oob', mediawiki_api_url=None, mediawiki_index_url=None, token_renew_period=1800, user_agent=None)[source]
This class is used to interact with the OAuth1 API.
- Parameters:
consumer_token (
Optional
[str
]) – The consumer tokenconsumer_secret (
Optional
[str
]) – The consumer secretaccess_token (
Optional
[str
]) – The access token (optional )access_secret (
Optional
[str
]) – The access secret (optional)callback_url (
str
) – The callback URL used to finalize the handshakemediawiki_api_url (
Optional
[str
]) – The URL to the MediaWiki API (default Wikidata)mediawiki_index_url (
Optional
[str
]) – The URL to the MediaWiki index (default Wikidata)token_renew_period (
int
) – Seconds after which a new token should be requested from the Wikidata serveruser_agent (
Optional
[str
]) – UA string to use for API requests.
- continue_oauth(oauth_callback_data=None)[source]
Continuation of OAuth procedure. Method must be explicitly called in order to complete OAuth. This allows external entities, e.g. websites, to provide tokens through callback URLs directly.
- Parameters:
oauth_callback_data (
Optional
[str
]) – The callback URL received to a Web app- Return type:
None
- Returns:
- generate_edit_credentials()
Request an edit token and update the cookie_jar in order to add the session cookie
- Return type:
RequestsCookieJar
- Returns:
Returns a json with all relevant cookies, aka cookie jar
- get_edit_cookie()
Can be called in order to retrieve the cookies from an instance of wbi_login.Login
- Return type:
RequestsCookieJar
- Returns:
Returns a json with all relevant cookies, aka cookie jar
- get_edit_token()
Can be called in order to retrieve the edit token from an instance of wbi_login.Login
- Return type:
Optional
[str
]- Returns:
returns the edit token
- get_session()
Returns the requests.Session object used for the login.
- Return type:
Session
- Returns:
Object of type requests.Session()
- class wikibaseintegrator.wbi_login.OAuth2(consumer_token=None, consumer_secret=None, mediawiki_api_url=None, mediawiki_rest_url=None, token_renew_period=1800, user_agent=None)[source]
Bases:
_Login
- Parameters:
consumer_token (str | None)
consumer_secret (str | None)
mediawiki_api_url (str | None)
mediawiki_rest_url (str | None)
token_renew_period (int)
user_agent (str | None)
- __init__(consumer_token=None, consumer_secret=None, mediawiki_api_url=None, mediawiki_rest_url=None, token_renew_period=1800, user_agent=None)[source]
This class is used to interact with the OAuth2 API.
- Parameters:
consumer_token (
Optional
[str
]) – The consumer tokenconsumer_secret (
Optional
[str
]) – The consumer secretmediawiki_api_url (
Optional
[str
]) – The URL to the MediaWiki API (default Wikidata)mediawiki_rest_url (
Optional
[str
]) – The URL to the MediaWiki REST API (default Wikidata)token_renew_period (
int
) – Seconds after which a new token should be requested from the Wikidata serveruser_agent (
Optional
[str
]) – UA string to use for API requests.
- generate_edit_credentials()
Request an edit token and update the cookie_jar in order to add the session cookie
- Return type:
RequestsCookieJar
- Returns:
Returns a json with all relevant cookies, aka cookie jar
- get_edit_cookie()
Can be called in order to retrieve the cookies from an instance of wbi_login.Login
- Return type:
RequestsCookieJar
- Returns:
Returns a json with all relevant cookies, aka cookie jar
- get_edit_token()
Can be called in order to retrieve the edit token from an instance of wbi_login.Login
- Return type:
Optional
[str
]- Returns:
returns the edit token
- get_session()
Returns the requests.Session object used for the login.
- Return type:
Session
- Returns:
Object of type requests.Session()