Skip to content

Commit

Permalink
[Story]: updated connectors oauth schema and connectors api
Browse files Browse the repository at this point in the history
  • Loading branch information
S-Nagendra committed Feb 14, 2024
1 parent 5ac75af commit 96fa951
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 41 deletions.
2 changes: 1 addition & 1 deletion core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def connector_check(request, workspace_id, connector_type, payload: ConnectorCon
if queryset.exists():
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
oauth_proxy_keys = config("OAUTH_SECRETS", default="", cast=Csv(str))
Expand Down
84 changes: 51 additions & 33 deletions core/oauth_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,99 +3,117 @@
"DEST_FACEBOOK-ADS": {
"type": "object",
"properties": {
"client_id": {
"AUTH_FACEBOOK_CLIENT_ID": {
"type": "string",
"description": "Facebook client id"
"description": "Facebook client id",
"title":"Client Id"
},
"client_secret": {
"AUTH_FACEBOOK_CLIENT_SECRET": {
"type": "string",
"description": "Facebook client secret"
"description": "Facebook client secret",
"title":"Client Secret"

}
},
"required": [
"client_id",
"client_secret"
"AUTH_FACEBOOK_CLIENT_ID",
"AUTH_FACEBOOK_CLIENT_SECRET"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
},
"DEST_GOOGLE-SHEETS": {
"type": "object",
"properties": {
"client_id": {
"AUTH_GOOGLE_CLIENT_ID": {
"type": "string",
"description": "Google client id"
"description": "Google client id",
"title":"Client Id"

},
"client_secret": {
"AUTH_GOOGLE_CLIENT_SECRET": {
"type": "string",
"description": "Google client secret"
"description": "Google client secret",
"title":"Client Secret"
}
},
"required": [
"client_id",
"client_secret"
"AUTH_GOOGLE_CLIENT_ID",
"AUTH_GOOGLE_CLIENT_SECRET"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
},
"DEST_GOOGLE-ADS": {
"type": "object",
"properties": {
"client_id": {
"AUTH_GOOGLE_CLIENT_ID": {
"type": "string",
"description": "Google client id"
"description": "Google client id",
"title":"Client Id"

},
"client_secret": {
"AUTH_GOOGLE_CLIENT_SECRET": {
"type": "string",
"description": "Google client secret"
"description": "Google client secret",
"title":"Client Secret"

},
"developer_token": {
"AUTH_GOOGLE_DEVELOPER_TOKEN": {
"type": "string",
"description": "Google developer token"
"description": "Google developer token",
"title":"Developer Token"
}
},
"required": [
"client_id",
"client_secret",
"developer_token"
"AUTH_GOOGLE_CLIENT_ID",
"AUTH_GOOGLE_CLIENT_SECRET",
"AUTH_GOOGLE_DEVELOPER_TOKEN"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
},
"DEST_SLACK": {
"type": "object",
"properties": {
"client_id": {
"AUTH_SLACK_CLIENT_ID": {
"type": "string",
"description": "Slack client id"
"description": "Slack client id",
"title":"Client Id"
},
"client_secret": {
"AUTH_SLACK_CLIENT_SECRET": {
"type": "string",
"description": "Slack client secret"
"description": "Slack client secret",
"title":"Client Secret"

}
},
"required": [
"client_id",
"client_secret"
"AUTH_SLACK_CLIENT_ID",
"AUTH_SLACK_CLIENT_SECRET"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
},
"DEST_HUBSPOT": {
"type": "object",
"properties": {
"client_id": {
"AUTH_HUBSPOT_CLIENT_ID": {
"type": "string",
"description": "Hubspot client id"
"description": "Hubspot client id",
"title":"Client Id"

},
"client_secret": {
"AUTH_HUBSPOT_CLIENT_SECRET": {
"type": "string",
"description": "Hubspot client secret"
"description": "Hubspot client secret",
"title":"Client Secret"

}
},
"required": [
"client_id",
"client_secret"
"AUTH_HUBSPOT_CLIENT_ID",
"AUTH_HUBSPOT_CLIENT_SECRET"
],
"additionalProperties": false,
"$schema": "http://json-schema.org/draft-07/schema#"
Expand Down
12 changes: 5 additions & 7 deletions valmi_app_backend/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from rest_framework import authentication
import json


class BearerAuthentication(authentication.TokenAuthentication):
Expand All @@ -15,10 +16,7 @@ class BearerAuthentication(authentication.TokenAuthentication):


def replace_values_in_json(json_obj, replacements):
for key, value in json_obj.items():
if isinstance(value, dict):
replace_values_in_json(value, replacements)
elif key in replacements:
replacement_value = replacements.get(key)
if replacement_value is not None:
json_obj[key] = replacement_value
config_str = json.dumps(json_obj)
for key in replacements:
config_str = config_str.replace(key, replacements[key])
return json.loads(config_str)

0 comments on commit 96fa951

Please sign in to comment.