elixir_wechat v0.1.2 WeChat.Adapter.Storage.ComponentClient behaviour
The storage adapter specification for WeChat component application.
Since we need to storage(cache) some key data(e.g. access_token
/component_access_token
) for invoking WeChat APIs, this module
is used for customizing the persistence when use this library in a :client
side of WeChat component application.
Writing custom storage adapter
Example for WeChat 3rd-party Platform application
defmodule MyComponentApp.Storage.Client do
@behaviour WeChat.Adapter.Storage.ComponentClient
@impl true
def get_access_token(appid, authorizer_appid) do
access_token = "Get authorizer's access_token by appid and authorizer_appid from your persistence..."
access_token
end
@impl ture
def get_component_access_token(appid) do
access_token = "Get component access_token by component appid from your persistence..."
access_token
end
@impl true
def refresh_access_token(appid, authorizer_appid, access_token) do
:ok
end
end
Link to this section Summary
Callbacks
Get authorizer's access_token for WeChat component application
Get access_token of WeChat component application
Refresh authorizer's access_token for WeChat component application
Link to this section Callbacks
Link to this callback
get_access_token(appid, authorizer_appid)
Get authorizer's access_token for WeChat component application.
Example
get_access_token(appid, authorizer_appid)
Link to this callback
get_component_access_token(appid)
Get access_token of WeChat component application.
Example
get_component_access_token(appid)
Link to this callback
refresh_access_token(appid, authorizer_appid, access_token)
Refresh authorizer's access_token for WeChat component application.
Example
refresh_access_token(
appid,
authorizer_appid,
access_token
)