aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhalcy <halcy@ARARAGI-KUN>2022-11-27 22:53:07 +0200
committerhalcy <halcy@ARARAGI-KUN>2022-11-27 22:53:07 +0200
commit9d2ee54790f9dedf3c1b3659ee312afcfb007fe2 (patch)
tree1cc8ba6d1297372749b609089b552c1a50e9e38a
parent50580a0c4941aec056df5e8523ae09bae912b7ce (diff)
downloadmastodon.py-9d2ee54790f9dedf3c1b3659ee312afcfb007fe2.tar.gz
Add client auth data to access token file
-rw-r--r--CHANGELOG.rst1
-rw-r--r--docs/index.rst18
-rw-r--r--mastodon/Mastodon.py14
3 files changed, 25 insertions, 8 deletions
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 2934f0d..cad7851 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -13,6 +13,7 @@ v1.8.0 (in progress)
13* Make the documentation a bit neater (thanks dieseltravis) 13* Make the documentation a bit neater (thanks dieseltravis)
14* Add the domain blocking admin API (`admin_domain_blocks`, `admin_domain_block`, `admin_update_domain_block`, `admin_delete_domain_block` - thanks catgoat) 14* Add the domain blocking admin API (`admin_domain_blocks`, `admin_domain_block`, `admin_update_domain_block`, `admin_delete_domain_block` - thanks catgoat)
15* Add the stats admin APIs (`admin_measures`, `admin_dimensions`, `admin_retention`) 15* Add the stats admin APIs (`admin_measures`, `admin_dimensions`, `admin_retention`)
16
16v1.7.0 17v1.7.0
17------ 18------
18* Cleaned code up a bit (thanks eumiro) 19* Cleaned code up a bit (thanks eumiro)
diff --git a/docs/index.rst b/docs/index.rst
index cb4610e..61aa916 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -54,10 +54,11 @@ node running Mastodon by setting `api_base_url` when creating the
54API object (or creating an app). 54API object (or creating an app).
55 55
56Mastodon.py aims to implement the complete public Mastodon API. As 56Mastodon.py aims to implement the complete public Mastodon API. As
57of this time, it is feature complete for Mastodon version 3.0.1. Pleroma's 57of this time, it is feature complete for Mastodon version 3.5.0. The
58Mastodon API layer, while not an official target, should also be basically 58Mastodon compatible API layers of various other pieces of software as well
59as forks, while not an official target, should also be basically
59compatible, and Mastodon.py does make some allowances for behaviour that isn't 60compatible, and Mastodon.py does make some allowances for behaviour that isn't
60strictly like that of Mastodon. 61strictly like that of Mastodon, and attempts to support extensions to the API.
61 62
62A note about rate limits 63A note about rate limits
63------------------------ 64------------------------
@@ -376,9 +377,12 @@ Mention dicts
376 'id': # Mentioned user's (local) account ID 377 'id': # Mentioned user's (local) account ID
377 } 378 }
378 379
379Scheduled toot dicts 380Scheduled status / toot dicts
380~~~~~~~~~~~~~~~~~~~~ 381~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
382.. _scheduled status dict:
383.. _scheduled status dicts:
381.. _scheduled toot dict: 384.. _scheduled toot dict:
385.. _scheduled toot dicts:
382 386
383.. code-block:: python 387.. code-block:: python
384 388
@@ -987,7 +991,9 @@ is specified, Mastodon.py defaults to https.
987.. automethod:: Mastodon.log_in 991.. automethod:: Mastodon.log_in
988.. _auth_request_url(): 992.. _auth_request_url():
989.. automethod:: Mastodon.auth_request_url 993.. automethod:: Mastodon.auth_request_url
990.. automedhod:: Mastodon.revoke_access_token 994.. _set_language():
995.. automethod:: Mastodon.set_language
996.. automethod:: Mastodon.revoke_access_token
991.. automethod:: Mastodon.create_account 997.. automethod:: Mastodon.create_account
992.. automethod:: Mastodon.email_resend_confirmation 998.. automethod:: Mastodon.email_resend_confirmation
993 999
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 61e7302..c3c02a0 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -450,6 +450,7 @@ class Mastodon:
450 with open(self.access_token, 'r') as token_file: 450 with open(self.access_token, 'r') as token_file:
451 self.access_token = token_file.readline().rstrip() 451 self.access_token = token_file.readline().rstrip()
452 452
453 # For newer versions, we also store the URL
453 try_base_url = token_file.readline().rstrip() 454 try_base_url = token_file.readline().rstrip()
454 if try_base_url is not None and len(try_base_url) != 0: 455 if try_base_url is not None and len(try_base_url) != 0:
455 try_base_url = Mastodon.__protocolize(try_base_url) 456 try_base_url = Mastodon.__protocolize(try_base_url)
@@ -457,6 +458,13 @@ class Mastodon:
457 raise MastodonIllegalArgumentError('Mismatch in base URLs between files and/or specified') 458 raise MastodonIllegalArgumentError('Mismatch in base URLs between files and/or specified')
458 self.api_base_url = try_base_url 459 self.api_base_url = try_base_url
459 460
461 # For EVEN newer vesions, we ALSO ALSO store the client id and secret so that you don't need to reauth to revoke
462 try:
463 self.client_id = token_file.readline().rstrip()
464 self.client_secret = token_file.readline().rstrip()
465 except:
466 pass
467
460 # Verify we have a base URL, protocolize 468 # Verify we have a base URL, protocolize
461 if self.api_base_url is None: 469 if self.api_base_url is None:
462 raise MastodonIllegalArgumentError("API base URL is required.") 470 raise MastodonIllegalArgumentError("API base URL is required.")
@@ -611,7 +619,7 @@ class Mastodon:
611 619
612 Handles password and OAuth-based authorization. 620 Handles password and OAuth-based authorization.
613 621
614 Will throw a `MastodonIllegalArgumentError` if the OAuth or the 622 Will throw a `MastodonIllegalArgumentError` if the OAuth flow data or the
615 username / password credentials given are incorrect, and 623 username / password credentials given are incorrect, and
616 `MastodonAPIError` if all of the requested scopes were not granted. 624 `MastodonAPIError` if all of the requested scopes were not granted.
617 625
@@ -664,6 +672,8 @@ class Mastodon:
664 with open(to_file, 'w') as token_file: 672 with open(to_file, 'w') as token_file:
665 token_file.write(response['access_token'] + "\n") 673 token_file.write(response['access_token'] + "\n")
666 token_file.write(self.api_base_url + "\n") 674 token_file.write(self.api_base_url + "\n")
675 token_file.write(self.client_id + "\n")
676 token_file.write(self.client_secret + "\n")
667 677
668 self.__logged_in_id = None 678 self.__logged_in_id = None
669 679
@@ -1132,7 +1142,7 @@ class Mastodon:
1132 * `update` - A status the logged in user has reblogged (and only those, as of 4.0.0) has been edited 1142 * `update` - A status the logged in user has reblogged (and only those, as of 4.0.0) has been edited
1133 * `status` - A user that the logged in user has enabned notifications for has enabled `notify` (see `account_follow()`_) 1143 * `status` - A user that the logged in user has enabned notifications for has enabled `notify` (see `account_follow()`_)
1134 * `admin.sign_up` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new user has signed up 1144 * `admin.sign_up` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new user has signed up
1135 * `admin.report ` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new report has been received 1145 * `admin.report` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new report has been received
1136 Parameters `exclude_types` and `types` are array of these types, specifying them will in- or exclude the 1146 Parameters `exclude_types` and `types` are array of these types, specifying them will in- or exclude the
1137 types of notifications given. It is legal to give both parameters at the same tine, the result will then 1147 types of notifications given. It is legal to give both parameters at the same tine, the result will then
1138 be the intersection of the results of both filters. Specifying `mentions_only` is a deprecated way to set 1148 be the intersection of the results of both filters. Specifying `mentions_only` is a deprecated way to set
Powered by cgit v1.2.3 (git 2.41.0)