You'll need to register an OAuth client account to receive a client_id, client_secret and other info for use with this module.
Visit the OAuth Documentation Pagewhile logged in as a Patreon creator on patreon.com to register your client.
Installation
Install with npm. You'll need to have Node.js installed.
npm install --save patreon
Usage
When you see 'pppp' replace pppp with the data you received setting up
your OAuth account or otherwise suggested by the inline comments.
var url = require('url')var patreon = require('patreon')var patreonAPI = patreon.patreonvar patreonOAuth = patreon.oauth// Use the client id and secret you received when setting up your OAuth accountvar CLIENT_ID = 'pppp'var CLIENT_SECRET = 'pppp'var patreonOAuthClient = patreonOAuth(CLIENT_ID, CLIENT_SECRET)// This should be one of the fully qualified redirect_uri you used when setting up your oauth accountvar redirectURL = 'http://mypatreonapp.com/oauth/redirect'function handleOAuthRedirectRequest(request, response) { var oauthGrantCode = url.parse(request.url,
var patreonOAuthClient = oauth(clientId, clientSecret)
Returns an object containing functions for fetching OAuth access tokens.
clientId The client id you received after setting up your OAuth account.
clientSecret The client secret you received after setting up your OAuth account.
This makes a request to grab tokens needed for making API requests, and returns a promise.
redirectCode Use the code query param provided to your OAauth redirect route.
redirectUri This should be the same redirect route you provided in the initial auth request.
The promise will be resolved with the parsed JSON containing a tokens response object,
or will be rejected with an error message.
You must pass tokens.access_token in to patreon for making API calls.
var client = patreon(accessToken)
Returns a function for making authenticated API calls.
client(pathname)
Returns a promise representing the result of the API call.
pathname API resource path like /current_user.
If the API call is successful, the promise will resolve with an object containing three pieces:
store: a JsonApiDataStore. This provides a nice, usable wrapper around the raw JSON:API response to easily access related resources and resource attributes.
rawJson: a JSON object in the JSON:API
format, for advanced custom usage (say, parsing into your own JSON:API data store)
response: the actual fetchResponse object, for the lowest level of response analysis
If the API call is unsuccessful, the promise will reject with an error.
You can request specific related resources
and or resource attributes
that you want returned by our API, as per the JSON:API specification.
The lists of valid includes and fields arguments are provided in patreon/schemas.
For instance, if you wanted to request the total amount a patron has ever paid to your campaign,
which is not included by default, you could do: