-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
To refresh your creator's access token you need to be connected via OAUth there was no example explaining how to do so. I recommend adding an example to the readme.md to explain how to do so.
This is the code i had to use in order to refresh the token
//Id, token, and secret loaded from patreon.txt file.
public static void refreshPatreonToken(String clientID, String clientSecret, String refreshToken) {
try {
PatreonOAuthpatreonOAuth = new PatreonOAuth(clientID, clientSecret, "");
PatreonOAuth.TokensResponse refresh = patreonOAuth.refreshTokens(refreshToken);
StringBuffer tokenData = new StringBuffer();
tokenData.append(refresh.getAccessToken() + "\n");
tokenData.append(clientID + "\n");
tokenData.append(clientSecret + "\n");
tokenData.append(refresh.getRefreshToken());
FileHandler.writeToFile(Constants.FILE_PATREON_TOKEN, tokenData.toString(), true);
patreonApi = new PatreonAPI(refresh.getAccessToken());
} catch (HttpStatusException e) {
if (e.getStatusCode() == 401) {
System.out.println("Refresh Token Invalid.);
return;
}
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}```Metadata
Metadata
Assignees
Labels
No labels