Atex.XRPC.OAuthClient (atex v0.6.0)
View SourceSummary
Types
@type t() :: %Atex.XRPC.OAuthClient{ access_token: String.t(), did: String.t(), dpop_key: JOSE.JWK.t(), dpop_nonce: (String.t() | nil) | nil, endpoint: String.t(), expires_at: NaiveDateTime.t(), issuer: String.t(), refresh_token: String.t() }
Functions
@spec from_conn(Plug.Conn.t()) :: {:ok, t()} | :error
Create an OAuthClient struct from a Plug.Conn.
Requires the conn to have passed through Plug.Session and
Plug.Conn.fetch_session/2 so that the session can be acquired and have the
atex_oauth key fetched from it.
Returns :error if the state is missing or is not the expected shape.
See Atex.XRPC.get/3.
@spec new( String.t(), String.t(), String.t(), String.t(), NaiveDateTime.t(), JOSE.JWK.t(), String.t() | nil ) :: t()
Create a new OAuthClient struct.
See Atex.XRPC.post/3.
Ask the client's OAuth server for a new set of auth tokens.
You shouldn't need to call this manually for the most part, the client does it's best to refresh automatically when it needs to.
@spec update_plug(Plug.Conn.t(), t()) :: Plug.Conn.t()
Updates a Plug.Conn session with the latest values from the client.
Ideally should be called at the end of routes where XRPC calls occur, in case the client has transparently refreshed, so that the user is always up to date.