kopia lustrzana https://github.com/halcy/Mastodon.py
Add client auth data to access token file
rodzic
50580a0c49
commit
9d2ee54790
|
@ -13,6 +13,7 @@ v1.8.0 (in progress)
|
|||
* Make the documentation a bit neater (thanks dieseltravis)
|
||||
* Add the domain blocking admin API (`admin_domain_blocks`, `admin_domain_block`, `admin_update_domain_block`, `admin_delete_domain_block` - thanks catgoat)
|
||||
* Add the stats admin APIs (`admin_measures`, `admin_dimensions`, `admin_retention`)
|
||||
|
||||
v1.7.0
|
||||
------
|
||||
* Cleaned code up a bit (thanks eumiro)
|
||||
|
|
|
@ -54,10 +54,11 @@ node running Mastodon by setting `api_base_url` when creating the
|
|||
API object (or creating an app).
|
||||
|
||||
Mastodon.py aims to implement the complete public Mastodon API. As
|
||||
of this time, it is feature complete for Mastodon version 3.0.1. Pleroma's
|
||||
Mastodon API layer, while not an official target, should also be basically
|
||||
of this time, it is feature complete for Mastodon version 3.5.0. The
|
||||
Mastodon compatible API layers of various other pieces of software as well
|
||||
as forks, while not an official target, should also be basically
|
||||
compatible, and Mastodon.py does make some allowances for behaviour that isn't
|
||||
strictly like that of Mastodon.
|
||||
strictly like that of Mastodon, and attempts to support extensions to the API.
|
||||
|
||||
A note about rate limits
|
||||
------------------------
|
||||
|
@ -376,9 +377,12 @@ Mention dicts
|
|||
'id': # Mentioned user's (local) account ID
|
||||
}
|
||||
|
||||
Scheduled toot dicts
|
||||
~~~~~~~~~~~~~~~~~~~~
|
||||
Scheduled status / toot dicts
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.. _scheduled status dict:
|
||||
.. _scheduled status dicts:
|
||||
.. _scheduled toot dict:
|
||||
.. _scheduled toot dicts:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
|
@ -987,7 +991,9 @@ is specified, Mastodon.py defaults to https.
|
|||
.. automethod:: Mastodon.log_in
|
||||
.. _auth_request_url():
|
||||
.. automethod:: Mastodon.auth_request_url
|
||||
.. automedhod:: Mastodon.revoke_access_token
|
||||
.. _set_language():
|
||||
.. automethod:: Mastodon.set_language
|
||||
.. automethod:: Mastodon.revoke_access_token
|
||||
.. automethod:: Mastodon.create_account
|
||||
.. automethod:: Mastodon.email_resend_confirmation
|
||||
|
||||
|
|
|
@ -450,6 +450,7 @@ class Mastodon:
|
|||
with open(self.access_token, 'r') as token_file:
|
||||
self.access_token = token_file.readline().rstrip()
|
||||
|
||||
# For newer versions, we also store the URL
|
||||
try_base_url = token_file.readline().rstrip()
|
||||
if try_base_url is not None and len(try_base_url) != 0:
|
||||
try_base_url = Mastodon.__protocolize(try_base_url)
|
||||
|
@ -457,6 +458,13 @@ class Mastodon:
|
|||
raise MastodonIllegalArgumentError('Mismatch in base URLs between files and/or specified')
|
||||
self.api_base_url = try_base_url
|
||||
|
||||
# For EVEN newer vesions, we ALSO ALSO store the client id and secret so that you don't need to reauth to revoke
|
||||
try:
|
||||
self.client_id = token_file.readline().rstrip()
|
||||
self.client_secret = token_file.readline().rstrip()
|
||||
except:
|
||||
pass
|
||||
|
||||
# Verify we have a base URL, protocolize
|
||||
if self.api_base_url is None:
|
||||
raise MastodonIllegalArgumentError("API base URL is required.")
|
||||
|
@ -611,7 +619,7 @@ class Mastodon:
|
|||
|
||||
Handles password and OAuth-based authorization.
|
||||
|
||||
Will throw a `MastodonIllegalArgumentError` if the OAuth or the
|
||||
Will throw a `MastodonIllegalArgumentError` if the OAuth flow data or the
|
||||
username / password credentials given are incorrect, and
|
||||
`MastodonAPIError` if all of the requested scopes were not granted.
|
||||
|
||||
|
@ -664,6 +672,8 @@ class Mastodon:
|
|||
with open(to_file, 'w') as token_file:
|
||||
token_file.write(response['access_token'] + "\n")
|
||||
token_file.write(self.api_base_url + "\n")
|
||||
token_file.write(self.client_id + "\n")
|
||||
token_file.write(self.client_secret + "\n")
|
||||
|
||||
self.__logged_in_id = None
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue