Skip to content

Add a way to add custom headers to conf.Client() return value #788

@klausman

Description

@klausman

Specifically, I want to add some X-headers to the request made after the auth dance has been done. As it is, I can't: using client.Do() just throws away all the work done. and client.Post (or Get) does not allow for header mix-in. Unless there is a way to do this and I just can't find it in the docs?

My current code, adjusted for brevity:

ctx := context.Background()
conf := &clientcredentials.Config{
    ClientID: "some ID",
    ClientSecret: "some Secret",
    TokenURL: "https://thatserver/api/v1/oauth2/token",
}

client := conf.Client(ctx)
rqbody := strings.NewReader("mybody{}")
// ***HERE***
res, err := client.Post("https://thatserver/superapi/?includes=B4181000", "application/json", rqbody)
// ... handle error, parse response etc.

At the ***HERE*** mark is where I'd expect to be able to add more headers. Returning an error if I try to clobber any of the headers OAuth2 needs is fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions