Search in sources :

Example 1 with PatreonAPI

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;
}
Also used : PatreonAPI(com.github.vaerys.objects.PatreonAPI)

Example 2 with 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);
    }
}
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

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