Skip to content

Commit 1f9afbe

Browse files
committed
Added a new param to the Twython __init__ that lets you select the authentication endpoint
for your application.
1 parent 66237c7 commit 1f9afbe

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

twython/api.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
class Twython(EndpointsMixin, object):
2424
def __init__(self, app_key=None, app_secret=None, oauth_token=None,
2525
oauth_token_secret=None, access_token=None, token_type='bearer',
26-
oauth_version=1, api_version='1.1', client_args=None):
26+
oauth_version=1, api_version='1.1', client_args=None, auth_endpoint='authenticate'):
2727
"""Instantiates an instance of Twython. Takes optional parameters for authentication and such (see below).
2828
2929
:param app_key: (optional) Your applications key
@@ -38,6 +38,9 @@ def __init__(self, app_key=None, app_secret=None, oauth_token=None,
3838
:param client_args: (optional) Accepts some requests Session parameters and some requests Request parameters.
3939
See http://docs.python-requests.org/en/latest/api/#sessionapi and requests section below it for details.
4040
[ex. headers, proxies, verify(SSL verification)]
41+
:param auth_endpoint: (optional) Lets you select which authentication endpoint will use your application.
42+
This will allow the application to have DM access if the endpoint is 'authorize'.
43+
Default: authenticate.
4144
4245
"""
4346

@@ -54,7 +57,7 @@ def __init__(self, app_key=None, app_secret=None, oauth_token=None,
5457
# OAuth 1
5558
self.request_token_url = self.api_url % 'oauth/request_token'
5659
self.access_token_url = self.api_url % 'oauth/access_token'
57-
self.authenticate_url = self.api_url % 'oauth/authenticate'
60+
self.authenticate_url = self.api_url % ('oauth/%s' % auth_endpoint)
5861

5962
if self.access_token: # If they pass an access token, force OAuth 2
6063
oauth_version = 2

0 commit comments

Comments
 (0)