View Source WeChat.TokenChecker (wechat v0.18.0)

Token 检查器

定期(默认为每 5 分钟检查一次)检查 access_token,如果发现失效,则自动刷新

按以下方式配置,将自动给对应的 client 增加检查

注意:此模块不支持企业微信

config :wechat, :check_token_for_clients, [ClientA, ClientB, ClientC]

Summary

Types

check_fun()

@type check_fun() :: (-> WeChat.response())

refresh_fun()

@type refresh_fun() :: (-> any())

Functions

add(id, check_fun, refresh_fun)

@spec add(id(), check_fun(), refresh_fun()) :: :ok

add_client(client)

@spec add_client(WeChat.client()) :: :ok | nil

add_client(client, refresh_options)

@spec add_client(WeChat.client(), refresh_options()) :: :ok

add_to_check_clients(client)

@spec add_to_check_clients(WeChat.client()) :: :ok

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

ids()

@spec ids() :: [id()]

maybe_add_client(client, refresh_options)

@spec maybe_add_client(WeChat.client(), refresh_options()) :: :ok

remove(id)

@spec remove(id()) :: :ok

remove_client(client)

@spec remove_client(WeChat.client()) :: :ok | nil

remove_from_check_clients(client)

@spec remove_from_check_clients(WeChat.client()) :: :ok

start_link(settings \\ %{})

@spec start_link(settings :: map()) :: GenServer.on_start()