View Source TwitchAPI.AuthStore (hello_twitch_api v0.5.1)
Storage for Twitch Auth.
The callback options
These can be useful for things like loading and saving the auth tokens to a more persisten store (or file) between app restarts or deploys.
The callback options accept either a module that implements the
TwitchAPI.AuthCallbacks
behaviour, a function, or a tuple in the standard
format of {Module, :function, [args]}
(MFA).
If you use an MFA the first two args passed to you function will still always
be name
and auth
, and the rest will be the ones you pass in [args]
.
They default to TwitchAPI.AuthNoop
unless you supply the :callback_module
option, this will be used instead.
:on_load
- Called after auth store init and before token is validated.:on_put
- Called whenTwitchAPI.Auth.t/0
is added to auth store or token is refreshed.:on_terminate
- Called when theTwitchAPI.AuthStore
terminates.
Summary
Types
See the TwitchAPI.AuthStore
module docs for an explanation.
The name
argument is the name used to register the auth store in the
Registry
, and is useful for distinguishing between different auth stores
if you have many.
Functions
Returns a specification to start this module under a supervisor.
Get the auth from the auth store.
Put the auth in the auth store.
Start the auth store.
Types
@type auth_store_callback() :: {module(), function :: atom(), args :: [term()]} | (name(), TwitchAPI.Auth.t() -> TwitchAPI.Auth.t()) | module()
See the TwitchAPI.AuthStore
module docs for an explanation.
@type name() :: term()
The name
argument is the name used to register the auth store in the
Registry
, and is useful for distinguishing between different auth stores
if you have many.
@type option() :: {:auth, TwitchAPI.Auth.t() | nil} | {:name, name()} | {:callback_module, module() | nil} | {:on_load, auth_store_callback() | nil} | {:on_put, auth_store_callback() | nil} | {:on_terminate, auth_store_callback() | nil}
@opaque state()
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec get(name() | pid()) :: TwitchAPI.Auth.t()
Get the auth from the auth store.
@spec put(name() | pid(), TwitchAPI.Auth.t()) :: :ok
Put the auth in the auth store.
@spec start_link([option()]) :: GenServer.on_start()
Start the auth store.