diff options
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 14 |
1 files changed, 12 insertions, 2 deletions
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 |