All Downloads are FREE. Search and download functionalities are using the official Maven repository.

dev.piste.api.val4j.apis.riotgames.official.RiotEntitlementsAuthAPI Maven / Gradle / Ivy

There is a newer version: 0.1.33
Show newest version
package dev.piste.api.val4j.apis.riotgames.official;

import com.google.gson.Gson;
import com.google.gson.JsonObject;
import dev.piste.api.val4j.http.RestClient;
import dev.piste.api.val4j.http.enums.ContentType;
import dev.piste.api.val4j.http.requests.PostRequestBuilder;
import dev.piste.api.val4j.http.requests.RestRequest;

import java.io.IOException;

/**
 * @author Piste  (GitHub)
 */
public class RiotEntitlementsAuthAPI {

    private final RestClient restClient;

    public RiotEntitlementsAuthAPI() {
        this.restClient = new RestClient("https://entitlements.auth.riotgames.com/api").enableSSL();
    }

    public String getEntitlementsToken(String accessToken) throws IOException {
        RestRequest restRequest = new PostRequestBuilder("", ContentType.JSON)
                .addPath("token").addPath("v1")
                .addHeader("Authorization", "Bearer " + accessToken)
                .build();

        JsonObject responseObject = restClient.sendRequest(restRequest).getAsJsonObject();

        return responseObject.get("entitlements_token").getAsString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy