Skip to content

Commit

Permalink
[Story]: failed to replace oauth_keys in connector discover - fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Nagendra committed Mar 4, 2024
1 parent 96fa951 commit 88a07f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 4 additions & 1 deletion core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,11 @@ def connector_check(request, workspace_id, connector_type, payload: ConnectorCon

if queryset.exists():
keys = queryset.first()

logger.debug("connector spec keys:-", keys)
# Replacing oauth keys with db values
payload.config = replace_values_in_json(payload.config, keys.oauth_config)

else:
# Replacing oauth keys with .env values
oauth_proxy_keys = config("OAUTH_SECRETS", default="", cast=Csv(str))
Expand Down Expand Up @@ -123,7 +126,7 @@ def connector_discover(request, workspace_id, connector_type, payload: Connector
keys = queryset.first()

# Replacing oauth keys with db values
replace_values_in_json(payload.config, keys.oauth_config)
payload.config = replace_values_in_json(payload.config, keys.oauth_config)

else:
# Replacing oauth keys with .env values
Expand Down
6 changes: 5 additions & 1 deletion core/engine_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ def get_all_syncs(request):

# Replacing Oauth keys
oauth_proxy_keys = config("OAUTH_SECRETS", default="", cast=Csv(str))

if len(oauth_proxy_keys) > 0:
for sync in syncs:
src_dst = [sync.source, sync.destination]

for obj in src_dst:
workspace = obj.credential.workspace
connector_type = obj.credential.connector.type
Expand All @@ -63,11 +65,13 @@ def get_all_syncs(request):
keys = queryset.first()

# Replacing oauth keys with db values
replace_values_in_json(obj.credential.connector_config, keys.oauth_config)
obj.credential.connector_config = replace_values_in_json(
obj.credential.connector_config, keys.oauth_config)
else:

# Replacing oauth keys with .env values
config_str = json.dumps(obj.credential.connector_config)

for key in oauth_proxy_keys:
config_str = config_str.replace(key, config(key))
obj.credential.connector_config = json.loads(config_str)
Expand Down

0 comments on commit 88a07f2

Please sign in to comment.