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

com.truelayer.java.auth.AuthenticationHandler Maven / Gradle / Ivy

There is a newer version: 16.0.0
Show newest version
package com.truelayer.java.auth;

import com.truelayer.java.ClientCredentials;
import com.truelayer.java.auth.entities.AccessToken;
import com.truelayer.java.auth.entities.GenerateOauthTokenRequest;
import com.truelayer.java.http.entities.ApiResponse;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import lombok.Value;

/**
 * {@inheritDoc}
 */
@Value
public class AuthenticationHandler implements IAuthenticationHandler {

    ClientCredentials clientCredentials;

    IAuthenticationApi authenticationApi;

    public static AuthenticationHandlerBuilder New() {
        return new AuthenticationHandlerBuilder();
    }

    @Override
    public CompletableFuture> getOauthToken(List scopes) {
        GenerateOauthTokenRequest generateOauthTokenRequest = GenerateOauthTokenRequest.builder()
                .clientId(clientCredentials.clientId())
                .clientSecret(clientCredentials.clientSecret())
                .scopes(scopes)
                .build();

        return authenticationApi.generateOauthToken(generateOauthTokenRequest);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy