<@U04S8PLJWMT> ```[ { "status": "success", ...
# ask-ai
h
@kapa.ai
Copy code
[
  {
    "status": "success",
    "api_key": ".ASPXAUTH=F9631DE75D68609A1BD693FAD5D7DB2E3EFC534A11104893A573A972B46FE71B70444FD62616263EECECEA6933xuxc4prkhhgxuy34xivrj; CompanyID=360 Live; Locale=Culture=en-US&TimeZone=GMTM0800A; UserBranch=; requestid=8173B09C1002728311F081B5DDD531A1; requeststat=+st:755+sc:~/entity/auth/login+start:638917246636035167+tg:",
    "debug": "8E697253D3ED910A1F5D72E7BB112CA44B24837A617F1A2F59FD3880AA37F047E",
    "http_status": 204
  }
]
this is my response i need to pass the session_token and use the api_key how to set the field
k
To configure Airbyte's Connector Builder to use the session token from your response, you need to extract the value of the
api_key
field from the response and inject it into your subsequent API requests. Based on your response:
Copy code
json [   {     "status": "success",     "api_key": ".ASPXAUTH=F9631DE75D68609A1BD693FAD5D7DB2E3EFC534A11104893A573A972B46FE71B70444FD62616263EECECEA6933xuxc4prkhhgxuy34xivrj; CompanyID=360 Live; Locale=Culture=en-US&TimeZone=GMTM0800A; UserBranch=; requestid=8173B09C1002728311F081B5DDD531A1; requeststat=+st:755+sc:~/entity/auth/login+start:638917246636035167+tg:",     "debug": "8E697253D3ED910A1F5D72E7BB112CA44B24837A617F1A2F59FD3880AA37F047E",     "http_status": 204   } ]
### How to Set the Field 1. Session Token Path: Set the session token path to
0.api_key
(since your response is a list with the token in the first object under the
api_key
key). 2. Injection Method: - If the API expects the token in a header, set the injection method to
header
and specify the header name (e.g.,
Authorization
or whatever your API requires). - If the API expects it as a query parameter, set the injection method to
request_parameter
and specify the parameter name. #### Example Configuration (YAML Reference)
Copy code
json {   "inject_into": "header",   "field_name": "Authorization" }
or
Copy code
json {   "inject_into": "request_parameter",   "field_name": "api_key" }
You will need to match the
field_name
to what your API expects for authentication. If it expects the token in the
Authorization
header, use that; otherwise, use the appropriate field name. #### In the Connector Builder UI - Choose Session Token authentication. - For the session token path, enter:
0.api_key
- For injection, select API Key. - Set the injection location (e.g., Header) and the field name (e.g.,
Authorization
or as required by your API). For more details, see the documentation on configuring session token authentication and API key injection: [Session Token Authenticator Configuration](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/authentication#configuration-1) [SessionTokenRequestApiKeyAuthenticator Reference](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/reference#/definitions/SessionTokenRequestApiKeyAuthenticator) If your API expects the token in a specific format (e.g.,
Bearer <token>
), you may need to adjust the value accordingly. --- Note: If you encounter issues referencing the token in the response (e.g., due to array structure), see the known limitations and workarounds discussed in [this GitHub issue](https://github.com/airbytehq/airbyte/issues/43320). The session token path must correctly point to the value in your response structure. If the connector builder does not support your exact response format, you may need to preprocess the response or request a feature enhancement.
h
@kapa.ai getting error
Copy code
session_token = dpath.get(next(self.decoder.decode(response)), self.session_token_path)
  File "/home/airbyte/.pyenv/versions/3.10.15/lib/python3.10/site-packages/dpath/__init__.py", line 192, in get
    raise KeyError(glob)
KeyError: ['0.api_key']
k
A message from kapa.ai
The error you're seeing:
Copy code
KeyError: ['0.api_key']
indicates that the session token path you provided (
0.api_key
) does not match the structure that Airbyte expects when extracting the session token from the response. According to the Airbyte documentation, the
session_token_path
should be an array of keys that forms a path into a JSON object response, not an array (list) of objects. For example, valid paths are
["access_token"]
or
["result", "token"]
if your response is:
Copy code
json {   "access_token": "TOKEN" }
or
Copy code
json {   "result": {     "token": "TOKEN"   } }
respectively. However, your response is a list (array) of objects:
Copy code
json [   {     "status": "success",     "api_key": "...",     ...   } ]
The current Airbyte session token extraction logic does not support extracting values from a list/array response, as confirmed by a [known issue](https://github.com/airbytehq/airbyte/issues/43320). The session token path expects to traverse a JSON object, not an array, and will raise a KeyError if you try to use an array index like
0
. What can you do? - If possible, modify the API or use a different endpoint that returns the token in a JSON object, not an array. - If you cannot change the API response, currently there is no built-in way in Airbyte's Connector Builder to extract a value from an array response for session token authentication. This is a limitation documented in the GitHub issue above. Summary: Airbyte's session token path does not support extracting tokens from a list/array response. You will encounter a KeyError if you try to use an array index in the path. This is a known limitation and there is no workaround in the Connector Builder at this time. You may need to request a feature or preprocess the response outside of Airbyte if possible. For more details, see the [GitHub issue discussing this limitation](https://github.com/airbytehq/airbyte/issues/43320) and the [official documentation on session token authentication](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/authentication#configuration-1).