forked from loafle/openapi-generator-original
[Python] support api key refresh in configuration module (#3594)
This commit is contained in:
committed by
William Cheng
parent
a4811c7850
commit
99fcfbc802
@@ -67,6 +67,9 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
||||
self.api_key_prefix = api_key_prefix
|
||||
"""dict to store API prefix (e.g. Bearer)
|
||||
"""
|
||||
self.refresh_api_key_hook = None
|
||||
"""function hook to refresh API key if expired
|
||||
"""
|
||||
self.username = username
|
||||
"""Username for HTTP basic authentication
|
||||
"""
|
||||
@@ -227,6 +230,8 @@ class Configuration(six.with_metaclass(TypeWithDefault, object)):
|
||||
:param identifier: The identifier of apiKey.
|
||||
:return: The token for api key authentication.
|
||||
"""
|
||||
if self.refresh_api_key_hook is not None:
|
||||
self.refresh_api_key_hook(self)
|
||||
key = self.api_key.get(identifier)
|
||||
if key:
|
||||
prefix = self.api_key_prefix.get(identifier)
|
||||
|
||||
Reference in New Issue
Block a user