View Source Tesla.Middleware.BearerAuth (tesla v1.12.1)

Bearer authentication middleware.

Adds a {"authorization", "Bearer <token>"} header.

Examples

defmodule MyClient do
  use Tesla

  # static configuration
  plug Tesla.Middleware.BearerAuth, token: "token"

  # dynamic token
  def new(token) do
    Tesla.client [
      {Tesla.Middleware.BearerAuth, token: token}
    ]
  end
end

Options

  • :token - token (defaults to "")