use of com.patreon.PatreonOAuth 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