alpaca icon indicating copy to clipboard operation
alpaca copied to clipboard

Default headers for clients

Open marfarma opened this issue 10 years ago • 3 comments

My API requires custom headers, for a use case similar to this scenario:

Where I've seen custom headers com up is in a system to system request operating on behalf of a user. The proxy system will validate the user and add "X-User: userid" to the headers and use the system credentials to hit the endpoint. The receiving system validates that the system credentials are authorized to act on behalf of the user, then validate that the user is authorized to perform the action. http://stackoverflow.com/a/9169270/149060

I was concerned that I didn't see support for them in the todo list.

marfarma avatar Apr 25 '14 20:04 marfarma

How do you think the client library should behave in this?

You can send headers when making an API call using the client. Wouldn't that solve this issue?

pksunkara avatar Apr 25 '14 23:04 pksunkara

@marfarma Could you describe this case more? Do you want the api clients to have some default headers?

pksunkara avatar May 14 '14 19:05 pksunkara

Yes, exactly that. In my case the API is to a service that implements a facade against another API. Attributes required to connect to that API must exist in each request against mine. Rather than pollute every request payload, I expect a header with those values.

My thoughts were that I should be able to define required connection constants, and associated header formatting, encoding, etc. The values would be assigned once per connection instance of the client library. The library then builds the required headers and inserts them on each request.

marfarma avatar May 15 '14 15:05 marfarma