This is an incomplete for the Patreon V2 API. Not all endpoints have wrapper functions yet.
For setup:
- You must first register a client on Patreon, when doing this select Client API V2.
The workflow is:
- Run
Patreon.Impl.authothorize_url/3
with the desired scopes - Go to the generated link and login or click "Allow"
- Pass the
code
parameter from the redirected URL intoPatreon.validate_code/1
and copy the access_token from the response - Pass the
access_token
intoPatreon.get_user/1
orPatreon.get_campaigns/1
Please note at this stage you will have to reference the API docs to know what params
you can pass into the get_*
functions.
If available in Hex, the package can be installed
by adding patreon_ex
to your list of dependencies in mix.exs
:
def deps do
[
{:patreon_ex, "~> 0.1.0"}
]
end
After importing you put your API secrets in a config file (that is in your .gitignore) and define wrapper functions for authorize_url/2
, authorize_url/3
, and validate_code/4
.
For example:
def authorize_url(scope) do
PatreonEx.authorize_url(
scope,
Application.get_env(:patreon_ex, :redirect_uri),
Application.get_env(:patreon_ex, :client_id)
)
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/patreon_ex.