Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom headers to the python client class #997

Open
jroseCCRI opened this issue Jul 24, 2024 · 2 comments
Open

Add custom headers to the python client class #997

jroseCCRI opened this issue Jul 24, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@jroseCCRI
Copy link

Description
Be able to add custom headers into the client when creating a Client object. Essentially we cannot use this python wrapper for our API because there is no way (that I was able to find at least) to insert your own custom headers. In our use case, we have special headers that must be passed into the request in order for any request to enter our host for meilisearch that we are using. Instead, we have to use the python requests library which works, but we would prefer to use the python wrapper that is here. Here is the hard-coded headers for reference:

self.headers = {
"Authorization": f"Bearer {self.config.api_key}",
"User-Agent": _build_user_agent(config.client_agents),
}

Basic example
If the proposal involves something new or a change, include a basic example. How would you use the feature? In which context?
Ideally we could do something like the following:
client = Client("host", "key", custom_headers= {"header_key_1": "header_value_1", "header_key_2": "header_value_2"})

Other
Any other things you want to add.

@curquiza
Copy link
Member

curquiza commented Aug 7, 2024

Hello thank you for the suggestion

@sanders41 what do you think (if you are around 😇)?

@sanders41
Copy link
Collaborator

@sanders41 what do you think (if you are around 😇)?

I see no reason not to. I actually already implemented this here and intended to do the same in this package but got busy and forgot. We should be able to more or less copy over what I did.

@jroseCCRI do you have any interest in creating a PR for this?

@curquiza curquiza added enhancement New feature or request good first issue Good for newcomers labels Aug 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants