Search in sources :

Example 1 with PatreonOAuth

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);
    }
}
Also used : PatreonOAuth(com.patreon.PatreonOAuth) HttpStatusException(org.jsoup.HttpStatusException) IOException(java.io.IOException) StringHandler(com.github.vaerys.handlers.StringHandler) PatreonAPI(com.github.vaerys.objects.PatreonAPI)

Aggregations

StringHandler (com.github.vaerys.handlers.StringHandler)1 PatreonAPI (com.github.vaerys.objects.PatreonAPI)1 PatreonOAuth (com.patreon.PatreonOAuth)1 IOException (java.io.IOException)1 HttpStatusException (org.jsoup.HttpStatusException)1