use of com.github.vaerys.objects.PatreonAPI in project DiscordSailv2 by Vaerys-Dawn.
the class Client method initPatreon.
public static PatreonAPI initPatreon(List<String> token) throws IndexOutOfBoundsException {
patreonApi = new PatreonAPI(token.get(0));
checkPatrons();
return patreonApi;
}
use of com.github.vaerys.objects.PatreonAPI in project DiscordSailv2 by Vaerys-Dawn.
the class Client method refreshPatreonToken.
public static void refreshPatreonToken(String clientID, String clientSecret, String refreshToken) {
try {
patreonOAuth = new PatreonOAuth(clientID, clientSecret, "");
PatreonOAuth.TokensResponse refresh = patreonOAuth.refreshTokens(refreshToken);
StringHandler tokenData = new StringHandler();
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) {
logger.error("Refresh Token is invalid.");
return;
}
Utility.sendStack(e);
} catch (IOException e) {
Utility.sendStack(e);
}
}
Aggregations