0

Does Boto3 client support connectors for GoogleAds and FacebookAds? According to documentation we can use Custom Connector but when i try to use it in the code i get the below error saying it should be one of the built in types.

[ERROR] ParamValidationError: Parameter validation failed:
Unknown parameter in connectorProfileConfig.connectorProfileProperties: "CustomConnector", must be one of: Amplitude, Datadog, Dynatrace, GoogleAnalytics, Honeycode, InforNexus, Marketo, Redshift, Salesforce, ServiceNow, Singular, Slack, Snowflake, Trendmicro, Veeva, Zendesk, SAPOData
Unknown parameter in connectorProfileConfig.connectorProfileCredentials: "CustomConnector", must be one of: Amplitude, Datadog, Dynatrace, GoogleAnalytics, Honeycode, InforNexus, Marketo, Redshift, Salesforce, ServiceNow, Singular, Slack, Snowflake, Trendmicro, Veeva, Zendesk, SAPOData
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 34, in lambda_handler
    response = client.create_connector_profile(
  File "/var/runtime/botocore/client.py", line 391, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/var/runtime/botocore/client.py", line 691, in _make_api_call
    request_dict = self._convert_to_request_dict(
  File "/var/runtime/botocore/client.py", line 739, in _convert_to_request_dict
    request_dict = self._serializer.serialize_to_request(
  File "/var/runtime/botocore/validate.py", line 360, in serialize_to_request
    raise ParamValidationError(report=report.generate_report())

Code in Lambda :

import json
import boto3

def lambda_handler(event, context):
    client = boto3.client('appflow')
  
    ### Google Ads
    response = client.create_connector_profile(
    connectorProfileName='GoogleAdsConn',
    connectorType='CustomConnector',
    # connectorLabel='GoogleAds',
    connectionMode='Public',
    connectorProfileConfig= {
      "connectorProfileProperties": {
          'CustomConnector': {
                # 'profileProperties': {
                #     'string': 'string'
                # },
                'oAuth2Properties': {
                    'tokenUrl': 'https://oauth2.googleapis.com/token',
                    'oAuth2GrantType': 'AUTHORIZATION_CODE'
                    # ,'tokenUrlCustomProperties': {
                    #     'string': 'string'
                    # }
                }
            }
            },
      "connectorProfileCredentials": {
        "CustomConnector": { 
            "authenticationType": "OAUTH2",
            "oauth2": { 
               "accessToken": "myaccesstoken",
               "clientId": "myclientid",
               "clientSecret": "myclientsecret",
              "oAuthRequest": { 
                 "authCode": "string",
                 "redirectUri": "string"
              },
               "refreshToken": "myrefreshtoken"
            }
      }
    }   
    }
   )
    return {
        'response': response
    }

Any leads on this will be appreciated.
Thanks!

1 Answers1

0

The issue was with older boto3 version. Adding a new lambda layer with latest boto3 version(1.24.70) and updating code with profileProperties it worked seamlessly. Below is the complete working code.

import json
import boto3

def lambda_handler(event, context):
    client = boto3.client('appflow')
    ### Google Ads
    response = client.create_connector_profile(
    connectorProfileName='GoogleAdsConnThruLambda',
    connectorType='CustomConnector',
    connectorLabel='GoogleAds',
    connectionMode='Public',
    connectorProfileConfig= {
        "connectorProfileProperties": {
            'CustomConnector': {
                'profileProperties': {
                        'developerToken': 'developerToken',
                        'instanceUrl':'https://googleads.googleapis.com',
                        'managerID':'managerID',
                        'apiVersion':'v11'
                },
                'oAuth2Properties': {
                    'tokenUrl': 'https://oauth2.googleapis.com/token',
                    'oAuth2GrantType': 'AUTHORIZATION_CODE'
                    # ,'tokenUrlCustomProperties': {
                        # "string":"string"   
                    # }
                }
            }
        },
        "connectorProfileCredentials": {
        "CustomConnector": {
            "authenticationType": "OAUTH2",
            "oauth2": {
                "accessToken": "accessToken",
                "clientId": "clientId",
                "clientSecret": "clientSecret",
                "oAuthRequest": {
                    "authCode": "authCode",
                    "redirectUri": "https://<your_region>.console.aws.amazon.com/appflow/oauth"
                },
                "refreshToken": "refreshToken"
            }
        }
    }
        }
        )
    
    
    return {
        'response': response

    }