public void setProviders(List<OAuthProvider> providers) {
   this.providers = providers;
   // for all providers
   for (OAuthProvider provider : providers) {
     BaseOAuthProvider baseProvider = (BaseOAuthProvider) provider;
     // calculate new callback url by adding the OAuth provider name
     baseProvider.setCallbackUrl(
         baseProvider.getCallbackUrl()
             + "?"
             + OAUTH_PROVIDER
             + "="
             + OAuthEncoder.encode(provider.getType()));
     // and init the provider
     provider.init();
   }
 }
  @Override
  protected Event doExecute(RequestContext context) throws Exception {

    HttpServletRequest request = WebUtils.getHttpServletRequest(context);
    HttpSession session = request.getSession();

    // get provider type
    String providerType = request.getParameter(OAUTH_PROVIDER);
    logger.debug("providerType : {}", providerType);
    // System.out.println("OAuthAction "+providerType+" "+StringUtils.isNotBlank(providerType));
    // it's an authentication
    if (StringUtils.isNotBlank(providerType)) {
      // get provider
      OAuthProvider provider = null;
      for (OAuthProvider aProvider : providers) {
        if (StringUtils.equals(providerType, aProvider.getType())) {
          provider = aProvider;
          break;
        }
      }
      logger.info("provider : {}", provider);

      // get credential
      System.out.println("Params " + request.getParameterMap());
      @SuppressWarnings("unchecked")
      OAuthCredential credential = provider.getCredential(request.getParameterMap());
      logger.info("credential : {}", credential);

      // retrieve service from session and put it into webflow
      Service service = (Service) session.getAttribute("service");
      context.getFlowScope().put("service", service);

      // create credentials
      Credentials credentials = new OAuthCredentials(credential);

      try {
        WebUtils.putTicketGrantingTicketInRequestScope(
            context, this.centralAuthenticationService.createTicketGrantingTicket(credentials));
        return success();
      } catch (final TicketException e) {
        e.printStackTrace();
        return error();
      }
    } else {
      // no authentication : go to login page

      // put service in session from flow scope
      Service service = (Service) context.getFlowScope().get("service");
      session.setAttribute("service", service);

      // for all providers, generate authorization urls
      for (OAuthProvider provider : providers) {
        String key = provider.getType() + "Url";
        String authorizatonUrl = provider.getAuthorizationUrl(new HttpUserSession(session));
        logger.debug("{} -> {}", key, authorizatonUrl);
        request.setAttribute(key, authorizatonUrl);
      }
    }

    return error();
  }