View Source LightningWeb.OauthCredentialHelper (Lightning v2.10.4)

A set of helper functions to encodes state and coordinate OAuth callbacks back to a LiveView component.

Summary

Functions

Broadcast a message specifically for forwarding a message to a component. It expects a subscription_id, the module of the component and opts being a keyword list containing an :id key of the specific component.

Encode and encrypt the callback data which will be sent so a provider as the state key in the request.

Subscribe to the oauth_credential topic. It expects the a unique ID for the topic, usually the LiveView's socket.id.

Functions

Link to this function

broadcast(subscription_id, msg)

View Source
Link to this function

broadcast_forward(subscription_id, mod, opts)

View Source

Broadcast a message specifically for forwarding a message to a component. It expects a subscription_id, the module of the component and opts being a keyword list containing an :id key of the specific component.

See: Phoenix.LiveView.send_update/3 for more info.

A corresponding LiveView (that is subscribed) is expected to have a matching handle_info/2 that looks like this:

def handle_info({:forward, mod, opts}, socket) do
  send_update(mod, opts)
  {:noreply, socket}
end
Link to this function

build_state(subscription_id, mod, component_id)

View Source

Encode and encrypt the callback data which will be sent so a provider as the state key in the request.

The values are:

  • subscription_id The same ID used to subscribe.
  • The component module The LiveView component that is going to receive update
  • The component id The ID of the component
Link to this function

subscribe(subscription_id)

View Source

Subscribe to the oauth_credential topic. It expects the a unique ID for the topic, usually the LiveView's socket.id.