aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py45
1 files changed, 21 insertions, 24 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 919825a..2e557e4 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -134,7 +134,6 @@ class Mastodon:
134 134
135 def auth_request_url(self, client_id = None, redirect_uris = "urn:ietf:wg:oauth:2.0:oob", scopes = ['read', 'write', 'follow']): 135 def auth_request_url(self, client_id = None, redirect_uris = "urn:ietf:wg:oauth:2.0:oob", scopes = ['read', 'write', 'follow']):
136 """Returns the url that a client needs to request the grant from the server. 136 """Returns the url that a client needs to request the grant from the server.
137 https://mastodon.social/oauth/authorize?client_id=XXX&response_type=code&redirect_uris=YYY&scope=read+write+follow
138 """ 137 """
139 if client_id is None: 138 if client_id is None:
140 client_id = self.client_id 139 client_id = self.client_id
@@ -155,22 +154,20 @@ class Mastodon:
155 code = None, redirect_uri = "urn:ietf:wg:oauth:2.0:oob", refresh_token = None,\ 154 code = None, redirect_uri = "urn:ietf:wg:oauth:2.0:oob", refresh_token = None,\
156 scopes = ['read', 'write', 'follow'], to_file = None): 155 scopes = ['read', 'write', 'follow'], to_file = None):
157 """ 156 """
158 Docs: https://github.com/doorkeeper-gem/doorkeeper/wiki/Interacting-as-an-OAuth-client-with-Doorkeeper 157 Your username is the e-mail you use to log in into mastodon.
159 158
160 Notes: 159 Can persist access token to file, to be used in the constructor.
161 Your username is the e-mail you use to log in into mastodon. 160
162 161 Supports refresh_token but Mastodon.social doesn't implement it at the moment.
163 Can persist access token to file, to be used in the constructor. 162
164 163 Handles password, authorization_code, and refresh_token authentication.
165 Supports refresh_token but Mastodon.social doesn't implement it at the moment. 164
166 165 Will throw a MastodonIllegalArgumentError if username / password
167 Handles password, authorization_code, and refresh_token authentication. 166 are wrong, scopes are not valid or granted scopes differ from requested.
168
169 Will throw a MastodonIllegalArgumentError if username / password
170 are wrong, scopes are not valid or granted scopes differ from requested.
171 167
172 Returns: 168 For OAuth2 documentation, compare https://github.com/doorkeeper-gem/doorkeeper/wiki/Interacting-as-an-OAuth-client-with-Doorkeeper
173 str @access_token 169
170 Returns the access token.
174 """ 171 """
175 if username is not None and password is not None: 172 if username is not None and password is not None:
176 params = self.__generate_params(locals(), ['scopes', 'to_file', 'code', 'refresh_token']) 173 params = self.__generate_params(locals(), ['scopes', 'to_file', 'code', 'refresh_token'])
@@ -383,15 +380,6 @@ class Mastodon:
383 params = self.__generate_params(locals(), ['id']) 380 params = self.__generate_params(locals(), ['id'])
384 return self.__api_request('GET', '/api/v1/accounts/' + str(id) + '/followers', params) 381 return self.__api_request('GET', '/api/v1/accounts/' + str(id) + '/followers', params)
385 382
386 def follows(self, uri):
387 """
388 Follow a remote user by uri (username@domain).
389
390 Returns a user dict.
391 """
392 params = self.__generate_params(locals())
393 return self.__api_request('POST', '/api/v1/follows', params)
394
395 def account_relationships(self, id): 383 def account_relationships(self, id):
396 """ 384 """
397 Fetch relationships (following, followed_by, blocking) of the logged in user to 385 Fetch relationships (following, followed_by, blocking) of the logged in user to
@@ -600,6 +588,15 @@ class Mastodon:
600 """ 588 """
601 return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/follow") 589 return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/follow")
602 590
591 def follows(self, uri):
592 """
593 Follow a remote user by uri (username@domain).
594
595 Returns a user dict.
596 """
597 params = self.__generate_params(locals())
598 return self.__api_request('POST', '/api/v1/follows', params)
599
603 def account_unfollow(self, id): 600 def account_unfollow(self, id):
604 """ 601 """
605 Unfollow a user. 602 Unfollow a user.
Powered by cgit v1.2.3 (git 2.41.0)