From 5c28d1ba75e32082aa0a60bacce960a4a9e03ae6 Mon Sep 17 00:00:00 2001 From: Lasse Edfast <8794658+lasseedfast@users.noreply.github.com> Date: Mon, 21 Aug 2023 22:20:23 +0200 Subject: [PATCH] Clearified the use of 'code' in log_in() --- README.rst | 9 +++++++++ mastodon/authentication.py | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index abae973..69de573 100644 --- a/README.rst +++ b/README.rst @@ -27,6 +27,15 @@ Feature complete for public API as of Mastodon version 3.5.5 and easy to get sta to_file = 'pytooter_usercred.secret' ) + # If you are logging in for the first time you need to give permissions to the app + # via OAuth, at the URL given by auth_request_url() and then pass code instead of + # username and password. + mastodon.log_in( + to_file = 'pytooter_usercred.secret', + code='code_from_oauth, + scopes=['read', 'write'], + ) + # Note that this won't work when using 2FA - you'll have to use OAuth, in that case. # To post, create an actual API instance: mastodon = Mastodon(access_token = 'pytooter_usercred.secret') diff --git a/mastodon/authentication.py b/mastodon/authentication.py index c7e2de6..4c4917f 100644 --- a/mastodon/authentication.py +++ b/mastodon/authentication.py @@ -315,7 +315,7 @@ class Mastodon(Internals): For OAuth 2, obtain a code via having your user go to the URL returned by :ref:`auth_request_url() ` and pass it as the code parameter. In this case, make sure to also pass the same redirect_uri parameter as you used when - generating the auth request URL. + generating the auth request URL. If passing `code`you should not pass `username` or `password`. Returns the access token as a string. """