Skip to content

Repository files navigation

patreon-java

Interact with the Patreon API via OAuth.

[Maven Central]

Get the artifact from Maven

<dependency>
<groupId>com.patreon</groupId>
<artifactId>patreon</artifactId>
<version>0.4.2</version>
</dependency>

Step 1. Get your client_id and client_secret

Visit the Patreon Platform Page while logged in as a Patreon creator to register your client.

This will provide you with a client_id and a client_secret.

Step 2. Use this library

For the Log In with Patreon flow

importcom.github.jasminb.jsonapi.JSONAPIDocument;
importcom.patreon.PatreonAPI;
importcom.patreon.PatreonOAuth;
importcom.patreon.PatreonOAuth;
importcom.patreon.resources.User;
importcom.patreon.resources.Pledge;
...
StringclientId = null; // Get this when you set up your clientStringclientSecret = null; // Get this when you set up your clientStringredirectUri = null; // Provide this to set up your clientStringcode = null; // Get this from the query parameter `code`PatreonOAuthoauthClient = newPatreonOAuth(clientId, clientSecret, redirectUri);
PatreonOAuth.TokensResponsetokens = oauthClient.getTokens(code);
//Store the refresh TokensResponse in your data storeStringaccessToken = tokens.getAccessToken();
PatreonAPIapiClient = newPatreonAPI(accessToken);
JSONAPIDocument<User> userResponse = apiClient.fetchUser();
Useruser = userResponse.get();
Log.i(user.getFullName());
List<Pledge> pledges = user.getPledges()
if (pledges != null && pledges.size() > 0) {
Pledgepledge = pledges.get(0);
Log.i(pledge.getAmountCents());
}
// You should save the user's PatreonOAuth.TokensResponse in your database// (for refreshing their Patreon data whenever you like),// along with any relevant user info or pledge info you want to store.

About

Interact with the Patreon API via OAuth

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages