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

com.factset.sdk.FactSetEstimatesReportBuilder.auth.FactSetOAuth2ClientAuth Maven / Gradle / Ivy

package com.factset.sdk.FactSetEstimatesReportBuilder.auth;

import com.factset.sdk.FactSetEstimatesReportBuilder.ApiException;
import com.factset.sdk.FactSetEstimatesReportBuilder.Pair;
import com.factset.sdk.utils.authentication.OAuth2Client;
import com.factset.sdk.utils.exceptions.AccessTokenException;
import com.factset.sdk.utils.exceptions.SigningJwsException;

import java.net.URI;
import java.util.List;
import java.util.Map;

public class FactSetOAuth2ClientAuth implements Authentication {

    private final OAuth2Client client;

    public FactSetOAuth2ClientAuth(OAuth2Client oauth2Client) {
        this.client = oauth2Client;
    }

    @Override
    public void applyToParams(List queryParams, Map headerParams,
                              Map cookieParams, String payload, String method, URI uri)
            throws ApiException {

        try {
            headerParams.put("Authorization", "Bearer " + client.getAccessToken());
        } catch (SigningJwsException | AccessTokenException e) {
            throw new ApiException(e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy