Hi all, I’m trying to add headers (basic auth) to ...
# ask-community
l
Hi all, I’m trying to add headers (basic auth) to the http request to the orion client. I have a python script to deploy flows and blocks. How am I supposed to update the client with httpx settings in my script ? thanks
k
Hi Luca, here's an example of adding the headers to a request.
l
Is there a way to pass headers to the actual OrionClient with httpx_settings? https://docs.prefect.io/api-ref/prefect/client/. I was hoping to do something like that:
with … as client:
deployment.apply()
k
yes, you can pass api, api_key, api_version, and httpx_settings to the OrionClient. https://docs.prefect.io/api-ref/prefect/client/#prefect.client.orion.OrionClient The api_key will add the authentication to the headers.
l
it seems that inject_client() could be what i’m looking for https://docs.prefect.io/api-ref/prefect/client/#prefect.client.orion.inject_client. I could inject the new client into my actual deployment script
k
are you using the create_deployment() call from the orion client?
l
No, at the moment my script looks like something like that:
Copy code
minio_block = RemoteFileSystem(...)
minio_block.save("minio")

k8s_job = KubernetesJob(...)
k8s_job.save('k8sdev')

deployment = Deployment.build_from_flow(
    flow=pipeline,
    storage=minio_block,
    infrastructure=k8s_job,
)

if __name__ == '__main__':
    deployment.apply()
What would be your suggestion to easily pass header to the client with such script ?
k
Hi Luca, I'm not entirely sure what you are trying to accomplish here? Can you provide more details about what you are trying to do with the Client or the deployment class?
l
Hi @Kalise Richmond, my prefect orion server sits behind a reverse proxy with basic authentification. I’m trying to transform the previous script to be compatible with such set up. I need to be able to pass the required settings to the underlying prefect client being called, while create deployment, infra, storage,…
thanks for your help