wechat_mp_auth v0.0.2 WechatMPAuth.Client
This module defines the WechatMPAuth.Client
struct and is responsible for building
and establishing a request for an component access token.
Summary
Functions
Get authorize url to get authorized
Returns an WechatMPAuth.AuthorizerAccessToken
struct that can then be used to access the
authorizer’s RESTful API.
Arguments
client
- aWechatMPAuth.Client
structparams
- a keyword list of request parameters
Returns an WechatMPAuth.ComponentAccessToken
struct that can then be used to access the
provider’s RESTful API.
Arguments
client
- aWechatMPAuth.Client
struct with the strategy to useparams
- a keyword list of request parameters
Same as get_component_access_token/2
but raises WechatMPAuth.Error
if an error occurs during the
request
Set multiple params in the client in one call
Builds a new WechatMPAuth client struct using the opts
provided.
Client struct fields
strategy
- a module that implements the Wechat MP Auth strategy, defaults toWechatMPAuth.Strategy.AuthCode
client_id
- the client_id for the Wechat Componentclient_secret
- the client_secret for the Wechat Componentsite
- the WechatMPAuth provider site hostauthorize_url
- absolute or relative URL path to the token endpoint. Defaults to"https://mp.weixin.qq.com/cgi-bin/componentloginpage"
authorizer_access_token_url
- absolute or relative URL path to the authorizer’s authorization endpoint. Defaults to"/component/api_query_auth"
component_access_token_url
- absolute or relative URL path to the component’s authorization endpoint. Defaults to"/component/api_component_token"
pre_auth_code_url
- absolute or relative URL path to the authentication code endpoint. Defaults to"/component/api_create_preauthcode"
params
- a map of request parametersredirect_uri
- the URI the provider should redirect to after authorization or token requests
Puts the specified value
in the params for the given key
.
The key can be a string
or an atom
. Atoms are automatically
convert to strings
Types
client_id :: binary
client_secret :: binary
component_access_token_url :: binary
pre_auth_code_url :: binary
redirect_uri :: binary
site :: binary
strategy :: module
t :: %WechatMPAuth.Client{authorize_url: authorize_url, authorizer_access_token_url: authorizer_access_token_url, client_id: client_id, client_secret: client_secret, component_access_token_url: component_access_token_url, params: params, pre_auth_code_url: pre_auth_code_url, redirect_uri: redirect_uri, site: site, strategy: strategy}
Functions
Get authorize url to get authorized.
Returns an WechatMPAuth.AuthorizerAccessToken
struct that can then be used to access the
authorizer’s RESTful API.
Arguments
client
- aWechatMPAuth.Client
structparams
- a keyword list of request parameters
Specs
get_component_access_token(t, params) ::
{:ok, WechatMPAuth.ComponentAccessToken.t} |
{:error, Error.t}
Returns an WechatMPAuth.ComponentAccessToken
struct that can then be used to access the
provider’s RESTful API.
Arguments
client
- aWechatMPAuth.Client
struct with the strategy to useparams
- a keyword list of request parameters
Specs
get_component_access_token!(t, params) ::
WechatMPAuth.ComponentAccessToken.t |
Error.t
Same as get_component_access_token/2
but raises WechatMPAuth.Error
if an error occurs during the
request.
Specs
merge_params(t, WechatMPAuth.params) :: t
Set multiple params in the client in one call.
Builds a new WechatMPAuth client struct using the opts
provided.
Client struct fields
strategy
- a module that implements the Wechat MP Auth strategy, defaults toWechatMPAuth.Strategy.AuthCode
client_id
- the client_id for the Wechat Componentclient_secret
- the client_secret for the Wechat Componentsite
- the WechatMPAuth provider site hostauthorize_url
- absolute or relative URL path to the token endpoint. Defaults to"https://mp.weixin.qq.com/cgi-bin/componentloginpage"
authorizer_access_token_url
- absolute or relative URL path to the authorizer’s authorization endpoint. Defaults to"/component/api_query_auth"
component_access_token_url
- absolute or relative URL path to the component’s authorization endpoint. Defaults to"/component/api_component_token"
pre_auth_code_url
- absolute or relative URL path to the authentication code endpoint. Defaults to"/component/api_create_preauthcode"
params
- a map of request parametersredirect_uri
- the URI the provider should redirect to after authorization or token requests