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

Bearer authentication middleware.

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

examples

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

Options

  • :token - token (defaults to "")