<@U04S8PLJWMT> i want to buid a CDK connector for...
# ask-ai
h
@kapa.ai i want to buid a CDK connector for acuamatica , here the api are working with cookies, how to build a cdk for this
k
To build a CDK connector for Acumatica where the API uses cookie-based authentication, you will need to implement a custom authenticator in your Airbyte Python CDK connector. The Airbyte CDK does not provide a built-in cookie authenticator, but you can create one by subclassing the
HttpAuthenticator
class. Here’s a high-level approach, based on an official example from the Airbyte community: 1. Create a custom authenticator that handles the login process, stores the cookies, and attaches them to subsequent requests. 2. Pass your custom authenticator to your stream classes. Below is a sample implementation:
Copy code
python from airbyte_cdk.sources.streams.http.auth import HttpAuthenticator import requests from urllib.parse import urljoin  class CookieAuthenticator(HttpAuthenticator):     def __init__(self, config):         self.url_base = config["url_base"]         self.cookie_jar = self.login(config["username"], config["password"])      def login(self, username, password):         login_body = {             "name": username,             "password": password         }         login_url = urljoin(self.url_base, "authenticatedSession")         resp = requests.post(url=login_url, json=login_body)         resp.raise_for_status()         return resp.cookies      def get_auth_header(self):         # Convert cookies to header format         return {"cookie": "; ".join([f"{k}={v}" for k, v in requests.utils.dict_from_cookiejar(self.cookie_jar).items()])}
You would then use this authenticator in your stream:
Copy code
python cookie_authenticator = CookieAuthenticator(config) custom_api_stream = CustomApiStream(config, authenticator=cookie_authenticator)
This approach keeps your authentication logic clean and follows Airbyte CDK best practices. You can adapt the login logic to match Acumatica’s specific authentication endpoint and payload requirements. For more details and the original discussion, see the [Airbyte forum post on cookie-based authentication](https://discuss.airbyte.io/t/549)<source>https://discuss.airbyte.io/t/549</source>. If you need more information on general connector development with the Python CDK, refer to the [Airbyte connector development documentation](https://docs.airbyte.com/platform/connector-development#connector-development-options)<source>https://docs.airbyte.com/platform/connector-development#connector-development-options</source>. Let me know if you need further guidance!