Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Patreon/patreon-java
Interact with the Patreon API via OAuth
https://github.com/Patreon/patreon-java
oauth patreon
Last synced: 11 days ago
JSON representation
Interact with the Patreon API via OAuth
- Host: GitHub
- URL: https://github.com/Patreon/patreon-java
- Owner: Patreon
- License: apache-2.0
- Created: 2015-10-10T20:49:57.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2024-01-29T19:34:34.000Z (10 months ago)
- Last Synced: 2024-08-01T19:42:16.936Z (3 months ago)
- Topics: oauth, patreon
- Language: Java
- Size: 209 KB
- Stars: 53
- Watchers: 95
- Forks: 26
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# patreon-java
Interact with the Patreon API via OAuth.[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.patreon/patreon/badge.svg)]
Get the artifact from [Maven](http://search.maven.org/#search|ga|1|g%3A%22com.patreon%22%20AND%20a%3A%22patreon%22)
```xmlcom.patreon
patreon
0.4.2```
This library is not maintained at the moment, and its not certain whether it will return to a maintained status and if so, when. So if you want to use this lib, forking it and adapting it to your needs would be the best option.
Step 1. Get your client_id and client_secret
---
Visit the [Patreon Platform Page](https://www.patreon.com/platform)
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
```java
import com.github.jasminb.jsonapi.JSONAPIDocument;
import com.patreon.PatreonAPI;
import com.patreon.PatreonOAuth;
import com.patreon.PatreonOAuth;
import com.patreon.resources.User;
import com.patreon.resources.Pledge;...
String clientId = null; // Get this when you set up your client
String clientSecret = null; // Get this when you set up your client
String redirectUri = null; // Provide this to set up your clientString code = null; // Get this from the query parameter `code`
PatreonOAuth oauthClient = new PatreonOAuth(clientId, clientSecret, redirectUri);
PatreonOAuth.TokensResponse tokens = oauthClient.getTokens(code);
//Store the refresh TokensResponse in your data store
String accessToken = tokens.getAccessToken();PatreonAPI apiClient = new PatreonAPI(accessToken);
JSONAPIDocument userResponse = apiClient.fetchUser();
User user = userResponse.get();
Log.i(user.getFullName());
List pledges = user.getPledges()
if (pledges != null && pledges.size() > 0) {
Pledge pledge = 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.
```