Modifying yaml file to refer to child API Key as bearer token for HighLevel connector

Summary

The user is looking to modify the yaml file for a new connector for HighLevel to refer to child API Keys as bearer tokens. They have extracted first-level information from the Agency API and need to pull data from multiple child records called ‘Locations’ under the Agency account.


Question

Hi, need help regarding developing new connector for HighLevel. I’ve Agency API Key to authenticate and extracted first level of information from the API. There are multiple child records called ‘Locations’ under the Agency account and each has its own API Key. I need to pull each Location data.

How can I modify the yaml file to refer the child API Key as bearer token? Following is excerpt from yaml file. How can modify the api_token: {{ config[''api_key''] }} to refer to the child api key? I hope my question make sense?

                    type: HttpRequester
                    url_base: <https://rest.gohighlevel.com/v1>
                    path: /locations
                    http_method: GET
                    request_parameters: {}
                    request_headers: {}
                    authenticator:
                      type: BearerAuthenticator
                      api_token: '{{ config[''api_key''] }}'
                    request_body_json: {}
                  record_selector:
                    type: RecordSelector
                    extractor:
                      type: DpathExtractor
                      field_path:
                        - locations```

<br>

---

This topic has been created from a Slack thread to give it more visibility.
It will be on Read-Only mode here. [Click here](https://airbytehq.slack.com/archives/C027KKE4BCZ/p1709103092517859) if you want to access the original thread.

[Join the conversation on Slack](https://slack.airbyte.com)

<sub>
["developing-new-connector", "highlevel", "yaml-file", "child-api-key", "bearer-token", "locations"]
</sub>

Based on the information provided in the extracts, to modify the YAML file to refer to the child API key as a bearer token, you would typically need to adjust the api_token field within the authenticator section of your YAML configuration. However, the extracts provided do not include a direct example of dynamically referencing child API keys for authentication purposes. The closest relevant information is about the BearerAuthenticator, which is used to set an HTTP header with a bearer token. In your case, you’re looking to dynamically switch or reference child API keys, which might involve more complex logic than what can be directly achieved through static YAML configuration alone. Given the extracts, here’s the relevant section for the BearerAuthenticator: yaml authenticator: type: "BearerAuthenticator" api_token: "hello" To modify this for your use case, assuming you have a way to dynamically determine the child API key (which is not covered in the provided extracts), you would theoretically replace the static api_token value with a reference to the child API key. However, the mechanism to dynamically fetch and insert a child API key in place of {{ config['api_key'] }} is not detailed in the extracts provided. For dynamic scenarios like yours, custom logic in the connector’s code might be necessary to fetch and use the correct child API key for each request. This could involve overriding the authentication method to fetch the appropriate child API key based on the context of the request or the data retrieved in previous steps. Since the extracts do not provide a direct solution to your question, and custom logic might be required beyond what can be specified in the YAML configuration, I recommend consulting the Airbyte documentation on custom connector development for more guidance on implementing dynamic authentication mechanisms: - Building a Python Source - Understanding the YAML file These links are based on the structure and content of the provided extracts and are meant to guide you towards the relevant sections of the Airbyte documentation that could help in developing a solution for your specific use case.

<@U04SE163WC8> thanks!! probably I didn’t make my question correctly. Here is my complete yaml file. I need to dynamically change the api_token to refer to a column value in parent stream.

type: DeclarativeSource
check:
  type: CheckStream
  stream_names:
    - Locations
streams:
  - type: DeclarativeStream
    name: Locations
    primary_key:
      - id
    schema_loader:
      type: InlineSchemaLoader
      schema:
        $schema: <http://json-schema.org/schema#>
        properties:
          address:
            type: string
          apiKey:
            type: string
          business:
            properties:
              address:
                type: string
              city:
                type: string
              country:
                type: string
              email:
                type: string
              name:
                type: string
              postalCode:
                type: string
              state:
                type: string
              timezone:
                type: string
              website:
                type: string
            type: object
          city:
            type: string
          country:
            type: string
          email:
            type: string
          firstName:
            type: string
          id:
            type: string
          lastName:
            type: string
          name:
            type: string
          phone:
            type: string
          postalCode:
            type: string
          settings:
            properties:
              allowDuplicateContact:
                type: boolean
              allowDuplicateOpportunity:
                type: boolean
              allowFacebookNameMerge:
                type: boolean
              disableContactTimezone:
                type: boolean
            type: object
          social:
            properties:
              blogRss:
                type: string
              facebookUrl:
                type: string
              foursquare:
                type: string
              googlePlaceId:
                type: string
              googlePlus:
                type: string
              instagram:
                type: string
              linkedIn:
                type: string
              pinterest:
                type: string
              twitter:
                type: string
              yelp:
                type: string
              youtube:
                type: string
            type: object
          state:
            type: string
          timezone:
            type: string
          website:
            type: string
        type: object
    retriever:
      type: SimpleRetriever
      requester:
        type: HttpRequester
        url_base: <https://rest.gohighlevel.com/v1>
        path: /locations
        http_method: GET
        request_parameters: {}
        request_headers: {}
        authenticator:
          type: BearerAuthenticator
          api_token: '{{ config[''api_key''] }}'
        request_body_json: {}
      record_selector:
        type: RecordSelector
        extractor:
          type: DpathExtractor
          field_path:
            - locations
      paginator:
        type: NoPagination
      partition_router: []
  - type: DeclarativeStream
    name: Contacts
    primary_key: []
    schema_loader:
      type: InlineSchemaLoader
      schema:
        $schema: <http://json-schema.org/draft-07/schema#>
        additionalProperties: true
        properties: {}
        type: object
    retriever:
      type: SimpleRetriever
      requester:
        type: HttpRequester
        url_base: <https://rest.gohighlevel.com/v1>
        path: /contacts
        http_method: GET
        request_parameters: {}
        request_headers: {}
        authenticator:
          type: BearerAuthenticator
          api_token: '{{ config[''api_key''] }}'
        request_body_json: {}
      record_selector:
        type: RecordSelector
        extractor:
          type: DpathExtractor
          field_path: []
      paginator:
        type: NoPagination
      partition_router:
        - type: SubstreamPartitionRouter
          parent_stream_configs:
            - type: ParentStreamConfig
              parent_key: apiKey
              request_option:
                type: RequestOption
                field_name: api_key2
                inject_into: header
              partition_field: locations
              stream:
                type: DeclarativeStream
                name: Locations
                primary_key:
                  - id
                schema_loader:
                  type: InlineSchemaLoader
                  schema:
                    $schema: <http://json-schema.org/schema#>
                    properties:
                      address:
                        type: string
                      apiKey:
                        type: string
                      business:
                        properties:
                          address:
                            type: string
                          city:
                            type: string
                          country:
                            type: string
                          email:
                            type: string
                          name:
                            type: string
                          postalCode:
                            type: string
                          state:
                            type: string
                          timezone:
                            type: string
                          website:
                            type: string
                        type: object
                      city:
                        type: string
                      country:
                        type: string
                      email:
                        type: string
                      firstName:
                        type: string
                      id:
                        type: string
                      lastName:
                        type: string
                      name:
                        type: string
                      phone:
                        type: string
                      postalCode:
                        type: string
                      settings:
                        properties:
                          allowDuplicateContact:
                            type: boolean
                          allowDuplicateOpportunity:
                            type: boolean
                          allowFacebookNameMerge:
                            type: boolean
                          disableContactTimezone:
                            type: boolean
                        type: object
                      social:
                        properties:
                          blogRss:
                            type: string
                          facebookUrl:
                            type: string
                          foursquare:
                            type: string
                          googlePlaceId:
                            type: string
                          googlePlus:
                            type: string
                          instagram:
                            type: string
                          linkedIn:
                            type: string
                          pinterest:
                            type: string
                          twitter:
                            type: string
                          yelp:
                            type: string
                          youtube:
                            type: string
                        type: object
                      state:
                        type: string
                      timezone:
                        type: string
                      website:
                        type: string
                    type: object
                retriever:
                  type: SimpleRetriever
                  requester:
                    type: HttpRequester
                    url_base: <https://rest.gohighlevel.com/v1>
                    path: /locations
                    http_method: GET
                    request_parameters: {}
                    request_headers: {}
                    authenticator:
                      type: BearerAuthenticator
                      api_token: '{{ config[''api_key''] }}'
                    request_body_json: {}
                  record_selector:
                    type: RecordSelector
                    extractor:
                      type: DpathExtractor
                      field_path:
                        - locations
                  paginator:
                    type: NoPagination
                  partition_router: []
spec:
  connection_specification:
    $schema: <http://json-schema.org/draft-07/schema#>
    type: object
    required:
      - api_key
    properties:
      api_key:
        type: string
        title: API Key
        airbyte_secret: true
        order: 0
    additionalProperties: true
  type: Spec
metadata:
  autoImportSchema:
    Locations: true
    Contacts: true```

Sorry <@U06L7K3HE76>, I seem to be having a bit of trouble. Don’t worry though, I’ve pinged my support folks and they will try to fix me up! :technologist:

Perhaps try again in 5mins?

Hello! How can I assist you with Airbyte today? If you have any questions or need guidance on using Airbyte, feel free to ask!

A message from http://kapa.ai|kapa.ai