package com.tofly.auth.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.RemoteTokenServices;

@Configuration
@Slf4j
public class AutoAPIConfiguration{

    @Value("${security.oauth2.resource.token-info-uri}")
    private String checkTokenEndpointUrl;
    @Value("${security.oauth2.client.client-id}")
    private String clientid;
    @Value("${security.oauth2.client.client-secret}")
    private String clientsecret;

    @Bean
    public RemoteTokenServices remoteTokenServices(){
        RemoteTokenServices remoteTokenServices = new RemoteTokenServices();
        remoteTokenServices.setCheckTokenEndpointUrl(checkTokenEndpointUrl);
        log.info("clientid --------------> {}, clientsecret --------------> {}", clientid,clientsecret);
        remoteTokenServices.setClientId(clientid);
        remoteTokenServices.setClientSecret(clientsecret);
        return  remoteTokenServices;
    }

}

