com.truelayer.java.auth.AuthenticationHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truelayer-java Show documentation
Show all versions of truelayer-java Show documentation
TrueLayer Java SDK for https://truelayer.com
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);
}
}