From d25e337c19b0f87027a88b51becd79c83c9667e5 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Wed, 26 Apr 2017 12:31:17 +0200 Subject: Update DEVELOPMENT.md --- DEVELOPMENT.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index eea45be..4693afe 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -8,11 +8,13 @@ Here's some general stuff to keep in mind, and some work that needs to be done * GET /api/v1/reports * POST /api/v1/reports * GET /api/v1/statuses/:id/card - + * PATCH /api/v1/accounts/update_credentials + * Documentation that needs to be updated: * Toot dicts are missing some fields (cards, applications, visibility) * Some others probably are missing stuff also - + * Follows is missclassified + * Other things missing: * Transparent as well as explicit pagination support * Tests (long-term goal) -- cgit v1.2.3 From 23e796bab4e19348d77a94cbcd27cd3539838cc5 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Wed, 26 Apr 2017 13:24:27 +0200 Subject: Fixed follows docs --- DEVELOPMENT.md | 1 - docs/index.rst | 4 ++-- mastodon/Mastodon.py | 18 +++++++++--------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 4693afe..f5d1583 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -13,7 +13,6 @@ Here's some general stuff to keep in mind, and some work that needs to be done * Documentation that needs to be updated: * Toot dicts are missing some fields (cards, applications, visibility) * Some others probably are missing stuff also - * Follows is missclassified * Other things missing: * Transparent as well as explicit pagination support diff --git a/docs/index.rst b/docs/index.rst index bad52d2..166b51e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -238,7 +238,6 @@ their relationships. .. automethod:: Mastodon.account_statuses .. automethod:: Mastodon.account_following .. automethod:: Mastodon.account_followers -.. automethod:: Mastodon.follows .. automethod:: Mastodon.account_relationships .. automethod:: Mastodon.account_search @@ -289,7 +288,8 @@ Writing data: Accounts These functions allow you to interact with other accounts: To (un)follow and (un)block. -.. automethod:: Mastodon.account_follow +.. automethod:: Mastodon.account_follow +.. automethod:: Mastodon.follows .. automethod:: Mastodon.account_unfollow .. automethod:: Mastodon.account_block .. automethod:: Mastodon.account_unblock diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 4717674..68f9e56 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -364,15 +364,6 @@ class Mastodon: params = self.__generate_params(locals(), ['id']) return self.__api_request('GET', '/api/v1/accounts/' + str(id) + '/followers', params) - def follows(self, uri): - """ - Follow a remote user by uri (username@domain). - - Returns a user dict. - """ - params = self.__generate_params(locals()) - return self.__api_request('POST', '/api/v1/follows', params) - def account_relationships(self, id): """ Fetch relationships (following, followed_by, blocking) of the logged in user to @@ -571,6 +562,15 @@ class Mastodon: """ return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/follow") + def follows(self, uri): + """ + Follow a remote user by uri (username@domain). + + Returns a user dict. + """ + params = self.__generate_params(locals()) + return self.__api_request('POST', '/api/v1/follows', params) + def account_unfollow(self, id): """ Unfollow a user. -- cgit v1.2.3 From 0ba01f3da99ac41708699ad85d527d98c555fc77 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Wed, 26 Apr 2017 13:29:34 +0200 Subject: Cleaned documentation up somewhat --- mastodon/Mastodon.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 68f9e56..003402f 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -134,7 +134,6 @@ class Mastodon: def auth_request_url(self, client_id = None, redirect_uris = "urn:ietf:wg:oauth:2.0:oob", scopes = ['read', 'write', 'follow']): """Returns the url that a client needs to request the grant from the server. - https://mastodon.social/oauth/authorize?client_id=XXX&response_type=code&redirect_uris=YYY&scope=read+write+follow """ if client_id is None: client_id = self.client_id @@ -155,22 +154,20 @@ class Mastodon: code = None, redirect_uri = "urn:ietf:wg:oauth:2.0:oob", refresh_token = None,\ scopes = ['read', 'write', 'follow'], to_file = None): """ - Docs: https://github.com/doorkeeper-gem/doorkeeper/wiki/Interacting-as-an-OAuth-client-with-Doorkeeper + Your username is the e-mail you use to log in into mastodon. - Notes: - Your username is the e-mail you use to log in into mastodon. - - Can persist access token to file, to be used in the constructor. - - Supports refresh_token but Mastodon.social doesn't implement it at the moment. - - Handles password, authorization_code, and refresh_token authentication. - - Will throw a MastodonIllegalArgumentError if username / password - are wrong, scopes are not valid or granted scopes differ from requested. + Can persist access token to file, to be used in the constructor. + + Supports refresh_token but Mastodon.social doesn't implement it at the moment. + + Handles password, authorization_code, and refresh_token authentication. + + Will throw a MastodonIllegalArgumentError if username / password + are wrong, scopes are not valid or granted scopes differ from requested. + + For OAuth2 documentation, compare https://github.com/doorkeeper-gem/doorkeeper/wiki/Interacting-as-an-OAuth-client-with-Doorkeeper - Returns: - str @access_token + Returns the access token. """ if username is not None and password is not None: params = self.__generate_params(locals(), ['scopes', 'to_file', 'code', 'refresh_token']) -- cgit v1.2.3 From 9766171729a18dd4ee28f09f2dfc150354dfcdc8 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Wed, 26 Apr 2017 13:31:06 +0200 Subject: Changed example to use .secret instead of .txt --- docs/index.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/index.rst b/docs/index.rst index 166b51e..87e6fb5 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -11,24 +11,24 @@ Mastodon.py ''' Mastodon.create_app( 'pytooterapp', - to_file = 'pytooter_clientcred.txt' + to_file = 'pytooter_clientcred.secret' ) ''' # Log in - either every time, or use persisted ''' - mastodon = Mastodon(client_id = 'pytooter_clientcred.txt') + mastodon = Mastodon(client_id = 'pytooter_clientcred.secret') mastodon.log_in( 'my_login_email@example.com', 'incrediblygoodpassword', - to_file = 'pytooter_usercred.txt' + to_file = 'pytooter_usercred.secret' ) ''' # Create actual instance mastodon = Mastodon( - client_id = 'pytooter_clientcred.txt', - access_token = 'pytooter_usercred.txt' + client_id = 'pytooter_clientcred.secret', + access_token = 'pytooter_usercred.secret' ) mastodon.toot('Tooting from python!') -- cgit v1.2.3