Tesla.Middleware.BasicAuth (tesla v1.5.0) View Source

Basic authentication middleware.

Wiki on the topic

Examples

defmodule MyClient do
  use Tesla

  # static configuration
  plug Tesla.Middleware.BasicAuth, username: "user", password: "pass"

  # dynamic user & pass
  def new(username, password, opts \\ %{}) do
    Tesla.client [
      {Tesla.Middleware.BasicAuth, Map.merge(%{username: username, password: password}, opts)}
    ]
  end
end

Options

  • :username - username (defaults to "")
  • :password - password (defaults to "")