55from typing import Union
66
77from cryptojwt .key_jar import KeyJar
8- from requests import request
98
109from idpyoidc .client .entity import Entity
1110from idpyoidc .client .exception import ConfigurationError
1211from idpyoidc .client .exception import OidcServiceError
1312from idpyoidc .client .exception import ParseError
1413from idpyoidc .client .service import REQUEST_INFO
15- from idpyoidc .client .service import Service
1614from idpyoidc .client .service import SUCCESSFUL
15+ from idpyoidc .client .service import Service
1716from idpyoidc .client .util import do_add_ons
1817from idpyoidc .client .util import get_deserialization_method
1918from idpyoidc .configure import Configuration
2019from idpyoidc .context import OidcContext
2120from idpyoidc .exception import FormatError
2221from idpyoidc .message import Message
2322from idpyoidc .message .oauth2 import is_error_message
23+ from requests import request
2424
2525__author__ = "Roland Hedberg"
2626
@@ -38,20 +38,20 @@ class Client(Entity):
3838 client_type = "oauth2"
3939
4040 def __init__ (
41- self ,
42- keyjar : Optional [KeyJar ] = None ,
43- config : Optional [Union [dict , Configuration ]] = None ,
44- services : Optional [dict ] = None ,
45- httpc : Optional [Callable ] = None ,
46- httpc_params : Optional [dict ] = None ,
47- context : Optional [OidcContext ] = None ,
48- upstream_get : Optional [Callable ] = None ,
49- key_conf : Optional [dict ] = None ,
50- entity_id : Optional [str ] = "" ,
51- verify_ssl : Optional [bool ] = True ,
52- jwks_uri : Optional [str ] = "" ,
53- client_type : Optional [str ] = "" ,
54- ** kwargs
41+ self ,
42+ keyjar : Optional [KeyJar ] = None ,
43+ config : Optional [Union [dict , Configuration ]] = None ,
44+ services : Optional [dict ] = None ,
45+ httpc : Optional [Callable ] = None ,
46+ httpc_params : Optional [dict ] = None ,
47+ context : Optional [OidcContext ] = None ,
48+ upstream_get : Optional [Callable ] = None ,
49+ key_conf : Optional [dict ] = None ,
50+ entity_id : Optional [str ] = "" ,
51+ verify_ssl : Optional [bool ] = True ,
52+ jwks_uri : Optional [str ] = "" ,
53+ client_type : Optional [str ] = "" ,
54+ ** kwargs
5555 ):
5656 """
5757
@@ -73,7 +73,7 @@ def __init__(
7373
7474 if client_type :
7575 self .client_type = client_type
76- elif config and ' client_type' in config :
76+ elif config and " client_type" in config :
7777 client_type = self .client_type = config ["client_type" ]
7878 else :
7979 client_type = self .client_type
@@ -85,7 +85,7 @@ def __init__(
8585 else :
8686 httpc_params = {"verify" : False }
8787
88- jwks_uri = jwks_uri or config .get (' jwks_uri' , '' )
88+ jwks_uri = jwks_uri or config .get (" jwks_uri" , "" )
8989
9090 Entity .__init__ (
9191 self ,
@@ -113,12 +113,12 @@ def __init__(
113113 do_add_ons (_add_ons , self ._service )
114114
115115 def do_request (
116- self ,
117- request_type : str ,
118- response_body_type : Optional [str ] = "" ,
119- request_args : Optional [dict ] = None ,
120- behaviour_args : Optional [dict ] = None ,
121- ** kwargs
116+ self ,
117+ request_type : str ,
118+ response_body_type : Optional [str ] = "" ,
119+ request_args : Optional [dict ] = None ,
120+ behaviour_args : Optional [dict ] = None ,
121+ ** kwargs
122122 ):
123123 _srv = self ._service [request_type ]
124124
@@ -141,14 +141,14 @@ def set_client_id(self, client_id):
141141 self .get_context ().set ("client_id" , client_id )
142142
143143 def get_response (
144- self ,
145- service : Service ,
146- url : str ,
147- method : Optional [str ] = "GET" ,
148- body : Optional [dict ] = None ,
149- response_body_type : Optional [str ] = "" ,
150- headers : Optional [dict ] = None ,
151- ** kwargs
144+ self ,
145+ service : Service ,
146+ url : str ,
147+ method : Optional [str ] = "GET" ,
148+ body : Optional [dict ] = None ,
149+ response_body_type : Optional [str ] = "" ,
150+ headers : Optional [dict ] = None ,
151+ ** kwargs
152152 ):
153153 """
154154
@@ -184,14 +184,14 @@ def get_response(
184184 return self .parse_request_response (service , resp , response_body_type , ** kwargs )
185185
186186 def service_request (
187- self ,
188- service : Service ,
189- url : str ,
190- method : Optional [str ] = "GET" ,
191- body : Optional [dict ] = None ,
192- response_body_type : Optional [str ] = "" ,
193- headers : Optional [dict ] = None ,
194- ** kwargs
187+ self ,
188+ service : Service ,
189+ url : str ,
190+ method : Optional [str ] = "GET" ,
191+ body : Optional [dict ] = None ,
192+ response_body_type : Optional [str ] = "" ,
193+ headers : Optional [dict ] = None ,
194+ ** kwargs
195195 ) -> Message :
196196 """
197197 The method that sends the request and handles the response returned.
@@ -320,10 +320,10 @@ def dynamic_provider_info_discovery(client: Client, behaviour_args: Optional[dic
320320 :param client: A :py:class:`idpyoidc.client.oidc.Client` instance
321321 """
322322
323- if client .client_type == ' oidc' and client .get_service ("provider_info" ):
324- service = ' provider_info'
325- elif client .client_type == ' oauth2' and client .get_service (' server_metadata' ):
326- service = ' server_metadata'
323+ if client .client_type == " oidc" and client .get_service ("provider_info" ):
324+ service = " provider_info"
325+ elif client .client_type == " oauth2" and client .get_service (" server_metadata" ):
326+ service = " server_metadata"
327327 else :
328328 raise ConfigurationError ("Can not do dynamic provider info discovery" )
329329
0 commit comments