// Path: src/main/java/com/google/api/ads/dfp/appengine/oauth/AuthorizationCodeFlowFactory.java
// public class AuthorizationCodeFlowFactory {
// 
//   private final CredentialStore credentialStore;
//   private final HttpTransport httpTransport;
//   private final JsonFactory jsonFactory;
//   private final String clientId;
//   private final String clientSecret;
//   private final String scope;
// 
//   @Inject
//   public AuthorizationCodeFlowFactory(CredentialStore credentialStore,
//       JsonFactory jsonFactory,
//       HttpTransport httpTransport,
//       @Named("clientId") String clientId,
//       @Named("clientSecret") String clientSecret,
//       @Named("scope") String scope) {
//     this.credentialStore = credentialStore;
//     this.httpTransport = httpTransport;
//     this.jsonFactory = jsonFactory;
//     this.clientId = clientId;
//     this.clientSecret = clientSecret;
//     this.scope = scope;
//   }
// 
//   /**
//    * Returns a fetcher for an API object.
//    *
//    * @return a Google authorization code flow
//    */
//   public GoogleAuthorizationCodeFlow getInstance() {
//     Preconditions.checkNotNull(clientId);
//     Preconditions.checkNotNull(clientSecret);
//     return new GoogleAuthorizationCodeFlow.Builder(
//         httpTransport,
//         jsonFactory,
//         clientId,
//         clientSecret,
//         Lists.newArrayList(scope))
//         .setCredentialStore(credentialStore)
//         .setApprovalPrompt("force")
//         .setAccessType("offline")
//         .build();
//   }
// 
// }


import com.google.api.ads.dfp.appengine.oauth.AuthorizationCodeFlowFactory;
import com.google.api.client.auth.oauth2.AuthorizationCodeFlow;
import com.google.api.client.auth.oauth2.AuthorizationCodeResponseUrl;
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.extensions.appengine.auth.oauth2.AbstractAppEngineAuthorizationCodeCallbackServlet;
import com.google.api.client.http.GenericUrl;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import java.io.IOException;
import java.util.logging.Logger;
import javax.inject.Singleton;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
// Copyright 2012 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.api.ads.dfp.appengine.servlet;




/**
 * Holds information used in the authorization flow, such as which URL to redirect to on
 * success/failure.
 *
 * @author Jeff Sham
 */
@Singleton
public class OAuth2CallbackServlet extends AbstractAppEngineAuthorizationCodeCallbackServlet {

  private static final Logger LOG = Logger.getLogger(OAuth2CallbackServlet.class.getName());
  private final AuthorizationCodeFlowFactory authorizationCodeFlowFactory;
  private final String redirectUrl;

  @Inject
// Path: src/main/java/com/google/api/ads/dfp/appengine/oauth/AuthorizationCodeFlowFactory.java
// public class AuthorizationCodeFlowFactory {
// 
//   private final CredentialStore credentialStore;
//   private final HttpTransport httpTransport;
//   private final JsonFactory jsonFactory;
//   private final String clientId;
//   private final String clientSecret;
//   private final String scope;
// 
//   @Inject
//   public AuthorizationCodeFlowFactory(CredentialStore credentialStore,
//       JsonFactory jsonFactory,
//       HttpTransport httpTransport,
//       @Named("clientId") String clientId,
//       @Named("clientSecret") String clientSecret,
//       @Named("scope") String scope) {
//     this.credentialStore = credentialStore;
//     this.httpTransport = httpTransport;
//     this.jsonFactory = jsonFactory;
//     this.clientId = clientId;
//     this.clientSecret = clientSecret;
//     this.scope = scope;
//   }
// 
//   /**
//    * Returns a fetcher for an API object.
//    *
//    * @return a Google authorization code flow
//    */
//   public GoogleAuthorizationCodeFlow getInstance() {
//     Preconditions.checkNotNull(clientId);
//     Preconditions.checkNotNull(clientSecret);
//     return new GoogleAuthorizationCodeFlow.Builder(
//         httpTransport,
//         jsonFactory,
//         clientId,
//         clientSecret,
//         Lists.newArrayList(scope))
//         .setCredentialStore(credentialStore)
//         .setApprovalPrompt("force")
//         .setAccessType("offline")
//         .build();
//   }
// 
// }


// Path: src/main/java/com/google/api/ads/dfp/appengine/servlet/OAuth2CallbackServlet.java
import com.google.api.ads.dfp.appengine.oauth.AuthorizationCodeFlowFactory;
import com.google.api.client.auth.oauth2.AuthorizationCodeFlow;
import com.google.api.client.auth.oauth2.AuthorizationCodeResponseUrl;
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.extensions.appengine.auth.oauth2.AbstractAppEngineAuthorizationCodeCallbackServlet;
import com.google.api.client.http.GenericUrl;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import java.io.IOException;
import java.util.logging.Logger;
import javax.inject.Singleton;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

// Copyright 2012 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.api.ads.dfp.appengine.servlet;




/**
 * Holds information used in the authorization flow, such as which URL to redirect to on
 * success/failure.
 *
 * @author Jeff Sham
 */
@Singleton
public class OAuth2CallbackServlet extends AbstractAppEngineAuthorizationCodeCallbackServlet {

  private static final Logger LOG = Logger.getLogger(OAuth2CallbackServlet.class.getName());
  private final AuthorizationCodeFlowFactory authorizationCodeFlowFactory;
  private final String redirectUrl;

  @Inject
  public OAuth2CallbackServlet(AuthorizationCodeFlowFactory authorizationCodeFlowFactory,