@@ -77,7 +77,7 @@ def __init__(
7777 super (OAuth2Session , self ).__init__ (** kwargs )
7878 self ._client = client or WebApplicationClient (client_id , token = token )
7979 self .token = token or {}
80- self .scope = scope
80+ self ._scope = scope
8181 self .redirect_uri = redirect_uri
8282 self .state = state or generate_token
8383 self ._state = state
@@ -97,6 +97,20 @@ def __init__(
9797 "protected_request" : set (),
9898 }
9999
100+ @property
101+ def scope (self ):
102+ """By default the scope from the client is used, except if overridden"""
103+ if self ._scope is not None :
104+ return self ._scope
105+ elif self ._client is not None :
106+ return self ._client .scope
107+ else :
108+ return None
109+
110+ @scope .setter
111+ def scope (self , scope ):
112+ self ._scope = scope
113+
100114 def new_state (self ):
101115 """Generates a state string to be used in authorizations."""
102116 try :
@@ -185,7 +199,7 @@ def fetch_token(
185199 force_querystring = False ,
186200 timeout = None ,
187201 headers = None ,
188- verify = True ,
202+ verify = None ,
189203 proxies = None ,
190204 include_client_id = None ,
191205 client_secret = None ,
@@ -325,7 +339,7 @@ def fetch_token(
325339
326340 headers = headers or {
327341 "Accept" : "application/json" ,
328- "Content-Type" : "application/x-www-form-urlencoded;charset=UTF-8 " ,
342+ "Content-Type" : "application/x-www-form-urlencoded" ,
329343 }
330344 self .token = {}
331345 request_kwargs = {}
@@ -388,7 +402,7 @@ def refresh_token(
388402 auth = None ,
389403 timeout = None ,
390404 headers = None ,
391- verify = True ,
405+ verify = None ,
392406 proxies = None ,
393407 ** kwargs
394408 ):
@@ -426,7 +440,7 @@ def refresh_token(
426440 if headers is None :
427441 headers = {
428442 "Accept" : "application/json" ,
429- "Content-Type" : ("application/x-www-form-urlencoded;charset=UTF-8 " ),
443+ "Content-Type" : ("application/x-www-form-urlencoded" ),
430444 }
431445
432446 r = self .post (
@@ -464,6 +478,7 @@ def request(
464478 withhold_token = False ,
465479 client_id = None ,
466480 client_secret = None ,
481+ files = None ,
467482 ** kwargs
468483 ):
469484 """Intercept all requests and add the OAuth 2 token if present."""
@@ -519,7 +534,7 @@ def request(
519534 log .debug ("Supplying headers %s and data %s" , headers , data )
520535 log .debug ("Passing through key word arguments %s." , kwargs )
521536 return super (OAuth2Session , self ).request (
522- method , url , headers = headers , data = data , ** kwargs
537+ method , url , headers = headers , data = data , files = files , ** kwargs
523538 )
524539
525540 def register_compliance_hook (self , hook_type , hook ):
0 commit comments