TwitchApi.OIDC (TwitchApi v0.1.2) View Source

This module provides a process to hold the state for twitch user access tokens

Link to this section Summary

Functions

Add state the Genserver state list

Returns a specification to start this module under a supervisor.

Delete state the Genserver state list

Callback function when the GenServer fetches the status. Filter sensitive data.

Returns the access token for the given user by user_id

Returns the access token for the given user by user_id

Returns the Genserver state

Callback for the GenServer to handle the state message for retieving previously created state.

:browser => Callback for the GenServer to handle the browser message :access_token => Callback for the GenServer to handle the user access token

Callback for the GenServer to handle the refresh message

Callback function when the GenServer is started

Request the access token for the previously authorized user

Function to send the message to refresh

Starts the GenServer

Link to this section Types

Specs

state() :: %TwitchApi.OIDC{
  state: [binary()],
  users_id: users_data(),
  users_name: users_data()
}

Specs

user_data() :: %{
  access_token: binary(),
  refresh_token: binary(),
  scope: binary(),
  token_type: binary(),
  expiration_time: integer(),
  time_issued: integer()
}

Specs

users_data() :: %{required(binary()) => user_data()}

Link to this section Functions

Link to this function

add_to_state(state_to_add)

View Source

Specs

add_to_state(binary()) :: :ok

Add state the Genserver state list

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

delete_from_state(state_to_delete)

View Source

Specs

delete_from_state(binary()) :: :ok

Delete state the Genserver state list

Link to this function

format_status(reason, list)

View Source

Specs

format_status(any(), list()) :: list()

Callback function when the GenServer fetches the status. Filter sensitive data.

Link to this function

get_access_token_id(user_id)

View Source

Specs

get_access_token_id(integer() | binary()) :: binary()

Returns the access token for the given user by user_id

Link to this function

get_access_token_name(user_name)

View Source

Specs

get_access_token_name(binary()) :: binary()

Returns the access token for the given user by user_id

Specs

get_state() :: binary()

Returns the Genserver state

Link to this function

handle_call(msg, from, state)

View Source

Callback for the GenServer to handle the state message for retieving previously created state.

:browser => Callback for the GenServer to handle the browser message :access_token => Callback for the GenServer to handle the user access token

Callback for the GenServer to handle the refresh message

Specs

init(any()) :: {:ok, state()}

Callback function when the GenServer is started

Link to this function

request_access_token(query_params)

View Source

Specs

request_access_token(map()) :: :ok

Request the access token for the previously authorized user

Link to this function

schedule_refresh(user_id, user_name, refresh_token, interval)

View Source

Specs

schedule_refresh(binary(), binary(), binary(), non_neg_integer()) :: reference()

Function to send the message to refresh

Specs

start_link(any()) :: :ignore | {:error, term()} | {:ok, pid()}

Starts the GenServer