https://kedro.org/ logo
#questions
Title
# questions
j

Justin Mayer

11/28/2023, 5:39 AM
Hello all 👋 , Can anyone explain me how to pass a
HTTPBasicAuth
to an
APIDataSet
?
Copy code
api_ds:
    type: api.APIDataSet
    url: <https://my_url.com/data>
    method: POST
    headers:
      Content-Type: application/json
    credentials: cred
credentials.yml
look like:
Copy code
cred:
    username: XxX
    password: XxX
It then become a tuple, but I would need to make use of
HTTPBasicAuth
function from requests instead. Thanks!
j

Justin Mayer

11/28/2023, 7:13 AM
Thanks! I managed to do:
Copy code
os.environ["key"] = json.dumps(
    {
        "username": "XxX",
        "password": "XxX",
    }
)

CONFIG_LOADER_ARGS = {
    "custom_resolvers": {
        "HTTPBasicAuth": lambda: HTTPBasicAuth(**json.loads(oc.env("key"))),
    },
}
Is there a way to take the credentials from the
credentials.yml
here?
t

Takieddine Kadiri

11/28/2023, 1:25 PM
Can you try this in your
credentials.yml
cred:
- username
- password
🌟 1
j

Justin Mayer

11/29/2023, 5:05 AM
WIth or without the custom_resolver @Takieddine Kadiri?
t

Takieddine Kadiri

11/29/2023, 8:33 AM
Without the custom_resolver
j

Justin Mayer

11/29/2023, 11:37 AM
Thank you! It works! Passing as a list instead of a dict.
🙌 1
2 Views