1515import six
1616import urllib
1717
18- from .session import pinned_session
18+ from .session import (
19+ API_HOST ,
20+ WEB_HOST ,
21+ pinned_session ,
22+ )
1923
2024if six .PY3 :
2125 url_path_quote = urllib .parse .quote # pylint: disable=no-member,useless-suppression
@@ -92,8 +96,6 @@ def __init__(self, consumer_key, consumer_secret, locale=None):
9296 self .locale = locale
9397 self .requests_session = pinned_session ()
9498
95- self ._host = os .environ .get ('DROPBOX_WEB_HOST' , 'www.dropbox.com' )
96-
9799 def _get_authorize_url (self , redirect_uri , state ):
98100 params = dict (response_type = 'code' ,
99101 client_id = self .consumer_key )
@@ -102,7 +104,7 @@ def _get_authorize_url(self, redirect_uri, state):
102104 if state is not None :
103105 params ['state' ] = state
104106
105- return self .build_url ('/oauth2/authorize' , params )
107+ return self .build_url ('/oauth2/authorize' , params , WEB_HOST )
106108
107109 def _finish (self , code , redirect_uri ):
108110 url = self .build_url ('/oauth2/token' )
@@ -155,7 +157,7 @@ def build_path(self, target, params=None):
155157 else :
156158 return target_path
157159
158- def build_url (self , target , params = None ):
160+ def build_url (self , target , params = None , host = API_HOST ):
159161 """Build an API URL.
160162
161163 This method adds scheme and hostname to the path
@@ -166,7 +168,7 @@ def build_url(self, target, params=None):
166168 :return: The full API URL.
167169 :rtype: str
168170 """
169- return "https://%s%s" % (self . _host , self .build_path (target , params ))
171+ return "https://%s%s" % (host , self .build_path (target , params ))
170172
171173
172174class DropboxOAuth2FlowNoRedirect (DropboxOAuth2FlowBase ):
0 commit comments