tesla v0.10.0 Tesla.Middleware.BasicAuth View Source

Basic authentication middleware

Wiki on the topic

Example

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.build_client [
      {Tesla.Middleware.BasicAuth, Map.merge(%{username: username, password: password}, opts)}
    ]
  end
end

Options

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

Link to this section Summary

Link to this section Functions

Callback implementation for Tesla.Middleware.call/3.