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)
|
* 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 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`)
|
* Add the stats admin APIs (`admin_measures`, `admin_dimensions`, `admin_retention`)
|
||||||
|
|
||||||
v1.7.0
|
v1.7.0
|
||||||
------
|
------
|
||||||
* Cleaned code up a bit (thanks eumiro)
|
* 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).
|
API object (or creating an app).
|
||||||
|
|
||||||
Mastodon.py aims to implement the complete public Mastodon API. As
|
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
|
of this time, it is feature complete for Mastodon version 3.5.0. The
|
||||||
Mastodon API layer, while not an official target, should also be basically
|
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
|
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
|
A note about rate limits
|
||||||
------------------------
|
------------------------
|
||||||
|
@ -376,9 +377,12 @@ Mention dicts
|
||||||
'id': # Mentioned user's (local) account ID
|
'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 dict:
|
||||||
|
.. _scheduled toot dicts:
|
||||||
|
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
|
@ -987,7 +991,9 @@ is specified, Mastodon.py defaults to https.
|
||||||
.. automethod:: Mastodon.log_in
|
.. automethod:: Mastodon.log_in
|
||||||
.. _auth_request_url():
|
.. _auth_request_url():
|
||||||
.. automethod:: Mastodon.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.create_account
|
||||||
.. automethod:: Mastodon.email_resend_confirmation
|
.. automethod:: Mastodon.email_resend_confirmation
|
||||||
|
|
||||||
|
|
|
@ -450,6 +450,7 @@ class Mastodon:
|
||||||
with open(self.access_token, 'r') as token_file:
|
with open(self.access_token, 'r') as token_file:
|
||||||
self.access_token = token_file.readline().rstrip()
|
self.access_token = token_file.readline().rstrip()
|
||||||
|
|
||||||
|
# For newer versions, we also store the URL
|
||||||
try_base_url = token_file.readline().rstrip()
|
try_base_url = token_file.readline().rstrip()
|
||||||
if try_base_url is not None and len(try_base_url) != 0:
|
if try_base_url is not None and len(try_base_url) != 0:
|
||||||
try_base_url = Mastodon.__protocolize(try_base_url)
|
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')
|
raise MastodonIllegalArgumentError('Mismatch in base URLs between files and/or specified')
|
||||||
self.api_base_url = try_base_url
|
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
|
# Verify we have a base URL, protocolize
|
||||||
if self.api_base_url is None:
|
if self.api_base_url is None:
|
||||||
raise MastodonIllegalArgumentError("API base URL is required.")
|
raise MastodonIllegalArgumentError("API base URL is required.")
|
||||||
|
@ -611,7 +619,7 @@ class Mastodon:
|
||||||
|
|
||||||
Handles password and OAuth-based authorization.
|
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
|
username / password credentials given are incorrect, and
|
||||||
`MastodonAPIError` if all of the requested scopes were not granted.
|
`MastodonAPIError` if all of the requested scopes were not granted.
|
||||||
|
|
||||||
|
@ -664,6 +672,8 @@ class Mastodon:
|
||||||
with open(to_file, 'w') as token_file:
|
with open(to_file, 'w') as token_file:
|
||||||
token_file.write(response['access_token'] + "\n")
|
token_file.write(response['access_token'] + "\n")
|
||||||
token_file.write(self.api_base_url + "\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
|
self.__logged_in_id = None
|
||||||
|
|
||||||
|
@ -1132,7 +1142,7 @@ class Mastodon:
|
||||||
* `update` - A status the logged in user has reblogged (and only those, as of 4.0.0) has been edited
|
* `update` - A status the logged in user has reblogged (and only those, as of 4.0.0) has been edited
|
||||||
* `status` - A user that the logged in user has enabned notifications for has enabled `notify` (see `account_follow()`_)
|
* `status` - A user that the logged in user has enabned notifications for has enabled `notify` (see `account_follow()`_)
|
||||||
* `admin.sign_up` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new user has signed up
|
* `admin.sign_up` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new user has signed up
|
||||||
* `admin.report ` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new report has been received
|
* `admin.report` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new report has been received
|
||||||
Parameters `exclude_types` and `types` are array of these types, specifying them will in- or exclude the
|
Parameters `exclude_types` and `types` are array of these types, specifying them will in- or exclude the
|
||||||
types of notifications given. It is legal to give both parameters at the same tine, the result will then
|
types of notifications given. It is legal to give both parameters at the same tine, the result will then
|
||||||
be the intersection of the results of both filters. Specifying `mentions_only` is a deprecated way to set
|
be the intersection of the results of both filters. Specifying `mentions_only` is a deprecated way to set
|
||||||
|
|
Ładowanie…
Reference in New Issue