Skip to content

Adding a header to a smithy client request? #328

Answered by daddykotex
Quafadas asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @Quafadas , good to see you here again. Hopefully, I'm able to help.

For more info on why we don't have out-of-the-box support for authentication, see #127. In the meantime, I'll provide you with a way to write a http4s middleware to tweak your http4s client to add the headers, it should be relatively simple.


Updated:

Relevant bits:

  // client middleware
  val authMiddleware: org.http4s.client.Middleware[IO] = { client =>
    Client { req =>
      client.run(
        req.withHeaders(
          headers.Authorization(Credentials.Token(AuthScheme.Bearer, "TOKEN"))
        )
      )
    }
  }

  val client = EmberClientBuilder.default[IO].build.map { client =>
    SimpleRestJsonBuilder(…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@Quafadas
Comment options

@Quafadas
Comment options

@Quafadas
Comment options

@Baccata
Comment options

@Quafadas
Comment options

Answer selected by Quafadas
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants