@@ -27,12 +27,13 @@ class OAuth2API(object):
2727 # override with 'Instagram', etc
2828 api_name = "Generic API"
2929
30- def __init__ (self , client_id = None , client_secret = None , client_ips = None , access_token = None , redirect_uri = None ):
30+ def __init__ (self , client_id = None , client_secret = None , client_ips = None , access_token = None , redirect_uri = None , timeout = None ):
3131 self .client_id = client_id
3232 self .client_secret = client_secret
3333 self .client_ips = client_ips
3434 self .access_token = access_token
3535 self .redirect_uri = redirect_uri
36+ self .timeout = timeout
3637
3738 def get_authorize_url (self , scope = None ):
3839 req = OAuth2AuthExchangeRequest (self )
@@ -100,7 +101,7 @@ def get_authorize_url(self, scope=None):
100101 return self ._url_for_authorize (scope = scope )
101102
102103 def get_authorize_login_url (self , scope = None ):
103- http_object = Http (disable_ssl_certificate_validation = True )
104+ http_object = Http (timeout = self . api . timeout , disable_ssl_certificate_validation = True )
104105
105106 url = self ._url_for_authorize (scope = scope )
106107 response , content = http_object .request (url )
@@ -112,7 +113,7 @@ def get_authorize_login_url(self, scope=None):
112113
113114 def exchange_for_access_token (self , code = None , username = None , password = None , scope = None , user_id = None ):
114115 data = self ._data_for_exchange (code , username , password , scope = scope , user_id = user_id )
115- http_object = Http (disable_ssl_certificate_validation = True )
116+ http_object = Http (timeout = self . api . timeout , disable_ssl_certificate_validation = True )
116117 url = self .api .access_token_url
117118
118119 headers = {"Content-Type" : "application/x-www-form-urlencoded" }
@@ -244,6 +245,9 @@ def make_request(self, url, method="GET", body=None, headers=None):
244245
245246 # https://github.com/jcgregorio/httplib2/issues/173
246247 # bug in httplib2 w/ Python 3 and disable_ssl_certificate_validation=True
247- http_obj = Http () if six .PY3 else Http (disable_ssl_certificate_validation = True )
248+ if six .PY3 :
249+ http_obj = Http (timeout = self .api .timeout )
250+ else :
251+ http_obj = Http (timeout = self .api .timeout , disable_ssl_certificate_validation = True )
248252
249253 return http_obj .request (url , method , body = body , headers = headers )
0 commit comments