add a human readable error when trying to log in with password on 4.4.0+

pull/397/head
halcy 2025-02-14 01:16:35 +02:00
rodzic 8f563d5e60
commit 1e62376f26
2 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -17,6 +17,7 @@ v2.0.0 (IN PROGRESS)
* Fixed a potential issue with modification to locals (Thanks Konano)
* Added support for 4.3.0 `accounts` endpoint (Thanks AlexKalopsia)
* Fix version parsing for GoToSocial (Thanks gmemstr)
* Updated docs to reflect the fact that startign with 4.4.0, the password grant type is no longer supported.
v1.8.1
------

Wyświetl plik

@ -320,6 +320,10 @@ class Mastodon(Internals):
Returns the access token as a string.
"""
# Is the version > 4.4.0? Throw on trying to log in with password with a more informative message than the API error
if self.mastodon_major >= 4 and self.mastodon_minor >= 4:
raise MastodonIllegalArgumentError('Password flow is no longer supported in Mastodon 4.4.0 and later.')
if username is not None and password is not None:
params = self.__generate_params(locals(), ['scopes', 'to_file', 'code', 'refresh_token'])
params['grant_type'] = 'password'