@@ -73,14 +73,14 @@ def __init__(
7373 "scope" : self .scope ,
7474 "token_endpoint" : self .token_endpoint ,
7575 }
76- create_authorization_url_params = {}
76+ self . create_authorization_url_params = {}
7777 if self .grant_type == GrantType .AUTHORIZATION_CODE_WITH_PKCE :
7878 if self .code_verifier is None :
7979 raise KindeConfigurationException (
8080 '"code_verifier" parameter is required when a grant_type is AUTHORIZATION_CODE_WITH_PKCE.'
8181 )
8282 auth_session_params ["code_challenge_method" ] = "S256"
83- create_authorization_url_params ["code_verifier" ] = self .code_verifier
83+ self . create_authorization_url_params ["code_verifier" ] = self .code_verifier
8484
8585 self .client = OAuth2Session (
8686 self .client_id ,
@@ -89,29 +89,35 @@ def __init__(
8989 ** auth_session_params ,
9090 )
9191
92+ self .login_url = ""
93+ self .registration_url = ""
94+
95+ self .jwks_client = PyJWKClient (
96+ uri = f"{ self .domain } /.well-known/jwks.json" ,
97+ cache_keys = True ,
98+ )
99+
100+ def _get_auth_url (self , state : str = None ):
92101 self .login_url , self .state = self .client .create_authorization_url (
93- self .authorization_endpoint , ** create_authorization_url_params
102+ self .authorization_endpoint , ** self . create_authorization_url_params , state = state
94103 )
95104
96105 if self .audience :
97106 self .login_url = f"{ self .login_url } &audience={ self .audience } "
98107 if self .org_code :
99108 self .login_url = f"{ self .login_url } &org_code={ self .org_code } "
100109
101- self .registration_url = f"{ self .login_url } &start_page=registration"
102- self .create_org_url = f"{ self .registration_url } &is_create_org=true"
103- self .jwks_client = PyJWKClient (
104- uri = f"{ self .domain } /.well-known/jwks.json" ,
105- cache_keys = True ,
106- )
107-
110+ def get_login_url (self , additional_params : Optional [Dict [str , str ]] = None , state : str = None ) -> str :
111+ self ._get_auth_url (state = state )
108112
109- def get_login_url (self , additional_params : Optional [Dict [str , str ]] = None ) -> str :
110113 if additional_params :
111114 return self ._add_additional_params (self .login_url , additional_params = additional_params )
112115 return self .login_url
113116
114- def get_register_url (self , additional_params : Optional [Dict [str , str ]] = None ) -> str :
117+ def get_register_url (self , additional_params : Optional [Dict [str , str ]] = None , state : str = None ) -> str :
118+ self ._get_auth_url (state = state )
119+ self .registration_url = f"{ self .login_url } &start_page=registration"
120+
115121 if additional_params :
116122 return self ._add_additional_params (self .registration_url , additional_params = additional_params )
117123 return self .registration_url
@@ -129,7 +135,7 @@ def is_authenticated(self) -> bool:
129135 return False
130136
131137 def create_org (self ) -> str :
132- return self .create_org_url
138+ return f" { self .registration_url } &is_create_org=true"
133139
134140 def get_claim (self , key : str , token_name : str = "access_token" ) -> Any :
135141 if token_name not in self .TOKEN_NAMES :
0 commit comments