View Source OAuth2TokenAgent.TokenAgent (oauth2_token_agent v0.1.0)
Defines the Agent used to manage the token and the struct it uses to store its state
Summary
Functions
Returns a specification to start this module under a supervisor.
Returns the current access token; if :inline_updates is configured, the token will be refreshed first if the strategy indicates it needs to be
Returns the current client instance; if :inline_updates is configured, the client will be refreshed first if the strategy indicates it needs to be
Triggers a refresh of the agent's tokens
Types
@type option() :: {:name, term()} | {:initial_client, OAuth2.Client.t()} | {:inline_refresh_strategy, OAuth2TokenAgent.TokenRefreshStrategy.t()}
@type t() :: %OAuth2TokenAgent.TokenAgent{ client_with_token: OAuth2.Client.t(), initial_client: OAuth2.Client.t(), inline_refresh_strategy: OAuth2TokenAgent.TokenRefreshStrategy.t() | nil, last_refreshed: Calendar.datetime(), name: String.t() }
Struct for tracking the state of the agent
Functions
Returns a specification to start this module under a supervisor.
See Supervisor
.
@spec get_access_token(Agent.agent()) :: String.t()
Returns the current access token; if :inline_updates is configured, the token will be refreshed first if the strategy indicates it needs to be
@spec get_current_client(Agent.agent()) :: OAuth2.Client.t()
Returns the current client instance; if :inline_updates is configured, the client will be refreshed first if the strategy indicates it needs to be
@spec refresh(Agent.agent()) :: :ok
Triggers a refresh of the agent's tokens
@spec start_link([option()]) :: Agent.on_start() | {:error, OAuth2.Response.t()} | {:error, OAuth2.Error.t()}