@@ -43,8 +43,10 @@ def __init__(self,
4343 log_file : str = None ,
4444 debug : bool = False ,
4545 logger : logging .Logger = None ,
46- proxy : str = None ):
46+ proxy : str = None ,
47+ gateway : str = "gateway" ):
4748 """Initialize an instance of organization."""
49+ self .gateway = gateway
4850 # set debug and file if specified and let the calling application dictate logging handlers
4951 self .log_file = log_file
5052 self .debug = debug
@@ -249,7 +251,8 @@ def __init__(self,
249251 self .logger .warning (f"unexpected environment '{ self .environment } '" )
250252
251253 if self .environment and not self .audience :
252- self .audience = f'https://gateway.{ self .environment } .netfoundry.io/'
254+ self .audience = f'https://{ self .gateway } .{ self .environment } .netfoundry.io/'
255+ self .logger .debug (f"computed audience URL from gateway and environment: { self .audience } " )
253256
254257 if self .environment and self .audience :
255258 if not re .search (self .environment , self .audience ):
@@ -284,15 +287,15 @@ def __init__(self,
284287 # extract the environment name from the authorization URL aka token API endpoint
285288 if self .environment is None :
286289 self .environment = re .sub (r'https://netfoundry-([^-]+)-.*' , r'\1' , token_endpoint , re .IGNORECASE )
287- self .logger .debug (f"using environment parsed from token_endpoint URL { self .environment } " )
290+ self .logger .debug (f"using environment parsed from authenticationUrl: { self .environment } " )
288291 # re: scope: we're not using scopes with Cognito, but a non-empty value is required;
289292 # hence "/ignore-scope"
290- scope = "https://gateway." + self .environment + ".netfoundry.io//ignore-scope"
293+ scope = f"https://{ self .gateway } .{ self .environment } .netfoundry.io//ignore-scope"
294+ self .logger .debug (f"computed scope URL from gateway and environment: { scope } " )
291295 # we can gather the URL of the API from the first part of the scope string by
292296 # dropping the scope suffix
293297 self .audience = scope .replace (r'/ignore-scope' , '' )
294- self .logger .debug (f"using audience parsed from token_endpoint URL { self .audience } " )
295- # e.g. https://gateway.production.netfoundry.io/
298+ self .logger .debug (f"using audience parsed from authenticationUrl: { self .audience } " )
296299 assertion = {
297300 "scope" : scope ,
298301 "grant_type" : "client_credentials"
0 commit comments