HaAuth.HA.OAuth behaviour (ha_auth v0.1.0)

Copy Markdown View Source

Home Assistant's OAuth2 (IndieAuth flavour): no client registration, the app's base URL is the client_id and the redirect URI is on the same host. See https://developers.home-assistant.io/docs/auth_api/

The browser goes to :auth_url; the code exchange, user lookup and revoke go server-side to :ha_url. The HA tokens are revoked as soon as the user is known. Swap in a stub with config :ha_auth, :oauth, Mod.

Summary

Functions

The configured implementation (this module unless stubbed).

Callbacks

authorize_url(client_id, redirect_uri, state)

@callback authorize_url(
  client_id :: String.t(),
  redirect_uri :: String.t(),
  state :: String.t()
) ::
  String.t()

sign_in(code, client_id)

@callback sign_in(code :: String.t(), client_id :: String.t()) ::
  {:ok, map()} | {:error, term()}

Functions

impl()

The configured implementation (this module unless stubbed).