1616from idpyoidc .exception import MessageException
1717from idpyoidc .exception import MissingRequiredAttribute
1818from idpyoidc .exception import NotForMe
19+ from idpyoidc .message import Message
1920from idpyoidc .message .oauth2 import is_error_message
2021from idpyoidc .message .oauth2 import ResponseMessage
2122from idpyoidc .message .oidc import AuthorizationRequest
3233
3334class StandAloneClient (Client ):
3435
35- def get_session_information (self , key , client = None ):
36+ def get_session_information (self ,key ):
3637 """
3738 This is the second of the methods users of this class should know about.
3839 It will return the complete session information as an
@@ -42,7 +43,7 @@ def get_session_information(self, key, client=None):
4243 :return: A State instance
4344 """
4445
45- return client .get_context ().cstate .get (key )
46+ return self .get_context ().cstate .get (key )
4647
4748 def do_provider_info (
4849 self ,
@@ -59,7 +60,7 @@ def do_provider_info(
5960
6061 _context = self .get_context ()
6162 _pi = _context .get ("provider_info" )
62- if _pi is None :
63+ if _pi is None or _pi == {} :
6364 dynamic_provider_info_discovery (self , behaviour_args = behaviour_args )
6465 _pi = _context .provider_info
6566 elif len (_pi ) == 1 and 'issuer' in _pi :
@@ -96,7 +97,11 @@ def do_provider_info(
9697 raise ValueError ("Unknown provider JWKS type: {}" .format (typ ))
9798
9899 _context .map_supported_to_preferred (info = _pi )
99- return _context .provider_info ['issuer' ]
100+
101+ try :
102+ return _context .provider_info ['issuer' ]
103+ except :
104+ return _context .issuer
100105
101106 def do_client_registration (
102107 self ,
@@ -338,7 +343,7 @@ def get_user_info(self, state, access_token="", **kwargs):
338343 return resp
339344
340345 @staticmethod
341- def userinfo_in_id_token (id_token , user_info_claims : Optional [List ] = None ):
346+ def userinfo_in_id_token (id_token : Message , user_info_claims : Optional [List ] = None ) -> dict :
342347 """
343348 Given a verified ID token return all the claims that may be user information.
344349
@@ -359,7 +364,6 @@ def finalize_auth(
359364 Given the response returned to the redirect_uri, parse and verify it.
360365
361366 :param behaviour_args: For finetuning behaviour
362- :param issuer: An Issuer ID
363367 :param response: The authorization response as a dictionary
364368 :return: An :py:class:`idpyoidc.message.oidc.AuthorizationResponse` or
365369 :py:class:`idpyoidc.message.oauth2.AuthorizationResponse` instance.
@@ -391,7 +395,11 @@ def finalize_auth(
391395 except KeyError :
392396 raise KeyError ("Unknown state value" )
393397
394- issuer = _context .provider_info ['issuer' ]
398+ try :
399+ issuer = _context .provider_info ['issuer' ]
400+ except KeyError :
401+ issuer = _context .issuer
402+
395403 if _iss != issuer :
396404 logger .error ("Issuer problem: {} != {}" .format (_iss , issuer ))
397405 # got it from the wrong bloke
@@ -550,7 +558,7 @@ def finalize(self, response, behaviour_args: Optional[dict] = None):
550558 "token" : token ["access_token" ],
551559 "id_token" : _id_token ,
552560 "session_state" : authorization_response .get ("session_state" , "" ),
553- "issuer" : _context .provider_info [ ' issuer' ]
561+ "issuer" : _context .issuer
554562 }
555563
556564 def has_active_authentication (self , state ):
0 commit comments