feat: support auth type like basic bearer and custom (#2613)
This commit is contained in:
parent
5bd3b02be6
commit
d44b05a9e5
10 changed files with 122 additions and 10 deletions
|
|
@ -62,6 +62,17 @@ class ApiTool(Tool):
|
|||
|
||||
if 'api_key_value' not in credentials:
|
||||
raise ToolProviderCredentialValidationError('Missing api_key_value')
|
||||
elif not isinstance(credentials['api_key_value'], str):
|
||||
raise ToolProviderCredentialValidationError('api_key_value must be a string')
|
||||
|
||||
if 'api_key_header_prefix' in credentials:
|
||||
api_key_header_prefix = credentials['api_key_header_prefix']
|
||||
if api_key_header_prefix == 'basic':
|
||||
credentials['api_key_value'] = f'Basic {credentials["api_key_value"]}'
|
||||
elif api_key_header_prefix == 'bearer':
|
||||
credentials['api_key_value'] = f'Bearer {credentials["api_key_value"]}'
|
||||
elif api_key_header_prefix == 'custom':
|
||||
pass
|
||||
|
||||
headers[api_key_header] = credentials['api_key_value']
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue