1 package de.juplo.facebook.errors;
4 import org.slf4j.Logger;
5 import org.slf4j.LoggerFactory;
6 import org.springframework.beans.BeansException;
7 import org.springframework.beans.factory.config.BeanPostProcessor;
8 import org.springframework.boot.autoconfigure.AutoConfigureAfter;
9 import org.springframework.boot.autoconfigure.security.oauth2.client.servlet.OAuth2ClientAutoConfiguration;
10 import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
11 import org.springframework.context.annotation.Bean;
12 import org.springframework.context.annotation.Configuration;
16 * Automatic configuration for Srping-Security-OAuth2
22 WebMvcAutoConfiguration.class,
23 OAuth2ClientAutoConfiguration.class
25 public class FacebookErrorsOAuth2AutoConfiguration
27 private static final Logger LOG =
28 LoggerFactory.getLogger(FacebookErrorsOAuth2AutoConfiguration.class);
31 static public BeanPostProcessor errorHandlerInjectorOAuth2()
33 LOG.info("Configuring OAuth2GraphApiErrorHandler for handling error-messages");
35 return new BeanPostProcessor()
38 public Object postProcessBeforeInitialization(
45 if (bean instanceof OAuth2RestTemplate)
47 LOG.debug("Injecting OAuth2GraphApiErrorHandler in {}", bean);
48 OAuth2RestTemplate template = (OAuth2RestTemplate) bean;
49 template.setErrorHandler(
50 new OAuth2GraphApiErrorHandler(
51 (OAuth2ErrorHandler)template.getErrorHandler()
60 public Object postProcessAfterInitialization(