<@U04S8PLJWMT> i need to Send User name and passwo...
# ask-ai
h
@kapa.ai i need to Send User name and password in Body, how to set up in airbyte custom connector, and it is also based on Cookie Managememt
k
To set up an Airbyte custom connector that sends the username and password in the request body and manages authentication via cookies, you have two main options depending on your use case: ### 1. Using the Connector Builder (Low-Code) If your API requires sending the username and password in the body to obtain a session token (which may be returned as a cookie), you can use the Session Token authentication method in the Connector Builder. Here’s how you can configure it: - Session Token Retrieval: - URL: Set to your login endpoint (e.g., `https://your.api.com/login`). - HTTP Method: Set to
POST
. - Authentication Method: Set to
No Auth
(since credentials are in the body). - Request Body: Use JSON key-value pairs: - Key:
username
, Value:
{{ config['username'] }}
- Key:
password
, Value:
{{ config['password'] }}
- Session Token Path: Set this to the path in the response where the session token or cookie value is found. - Expiration Duration: Set to the expected duration of the session. > For APIs like Metabase, this approach is documented and works for session tokens. If your API returns a cookie, you may need to extract the cookie value from the response and use it in subsequent requests. However, the Connector Builder does not natively handle cookies as authentication tokens; for more advanced cookie management, see the next option [Session Token Auth Configuration](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/authentication#configuration). ### 2. Using the Python CDK (Advanced, for Cookie Management) If you need to handle cookies directly (e.g., the API returns a
Set-Cookie
header and expects the cookie in subsequent requests), you should implement a custom authenticator in Python using the Airbyte CDK. Here’s an example approach:
Copy code
python class CookieAuthenticator(HttpAuthenticator):     def __init__(self, config):         self.cookie_jar = self.login(config["username"], config["password"])      def login(self, username, password):         login_body = {             "username": username,             "password": password         }         login_url = urljoin(self.url_base, "login")         resp = requests.post(url=login_url, json=login_body)         resp.raise_for_status()         return resp.cookies      def get_auth_header(self) -> Mapping[str, Any]:         return {"cookie": "; ".join([f"{k}={v}" for k, v in requests.utils.dict_from_cookiejar(self.cookie_jar).items()])}
You would then pass this authenticator to your custom stream. This approach allows you to fully manage cookies as required by your API [Forum: Cookie-based authentication with Airbyte](https://discuss.airbyte.io/t/549). --- Summary: - Use the Connector Builder for simple session token flows where credentials are sent in the body. - Use the Python CDK for advanced cookie management, where you need to handle
Set-Cookie
and send cookies in subsequent requests. If you need more advanced cookie handling than the Connector Builder supports, the Python CDK is the recommended approach.
h
@kapa.ai i'm using low code connector builder, now i should send, suername and password in body , json form, how to achieve it?
k
A message from kapa.ai
To send the username and password in the request body as JSON using the Airbyte low-code Connector Builder, you should use the Session Token authentication method. Here’s how you can configure it: 1. Go to the Authentication section in the Connector Builder. 2. Select "Session Token" as the authentication method. 3. In the Session Token Retrieval configuration: - URL: Enter the endpoint where you need to send the credentials (e.g., `https://your.api.com/login`). - HTTP Method: Set to
POST
. - Authentication Method: Set to
No Auth
(since you are sending credentials in the body, not as headers). - Request Body: Choose
JSON (key-value pairs)
and add: - Key:
username
, Value:
{{ config['username'] }}
- Key:
password
, Value:
{{ config['password'] }}
This setup will send a POST request with a JSON body containing the username and password when retrieving the session token. You can then configure how to extract the session token from the response and use it for subsequent requests. For a detailed example (using Metabase as a reference), see the documentation: - [Session Token Auth Configuration](https://docs.airbyte.com/platform/connector-development/connector-builder-ui/authentication#configuration) This approach is supported in the low-code connector builder and is the recommended way to send credentials in the request body as JSON.