当前位置: 首页>>代码示例>>Java>>正文


Java UrlFetchTransport类代码示例

本文整理汇总了Java中com.google.api.client.extensions.appengine.http.UrlFetchTransport的典型用法代码示例。如果您正苦于以下问题:Java UrlFetchTransport类的具体用法?Java UrlFetchTransport怎么用?Java UrlFetchTransport使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UrlFetchTransport类属于com.google.api.client.extensions.appengine.http包,在下文中一共展示了UrlFetchTransport类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildCodeFlow

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
/**
   * Gets the credentials stored in GAE. If expired, uses the refresh token to
   * get a new access token from OAuth
   * @return
   * @throws IOException
   */
// START:flow
  public static AuthorizationCodeFlow buildCodeFlow()
      throws IOException
  {
    return new GoogleAuthorizationCodeFlow.Builder(
        new UrlFetchTransport(),
        new JacksonFactory(),
        WEB_CLIENT_ID,
        WEB_CLIENT_SECRET,
        SCOPES)
    .setApprovalPrompt( "force" )
    .setAccessType("offline")
    .setCredentialDataStore( getDataStore() )
    .build();
  }
 
开发者ID:pthakkar9,项目名称:mirror-api-book-chap3,代码行数:22,代码来源:AuthUtils.java

示例2: create

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
/**
 * Returns a new connection to Bigquery, first ensuring that the given dataset exists in the
 * project with the given id, creating it if required.
 */
public Bigquery create(String projectId, String datasetId) throws IOException {
  Bigquery bigquery = create(
      getClass().getSimpleName(),
      new UrlFetchTransport(),
      new JacksonFactory(),
      new AppIdentityCredential(BigqueryScopes.all()));

  // Note: it's safe for multiple threads to call this as the dataset will only be created once.
  if (!knownExistingDatasets.contains(datasetId)) {
    ensureDataset(bigquery, projectId, datasetId);
    knownExistingDatasets.add(datasetId);
  }

  return bigquery;
}
 
开发者ID:google,项目名称:nomulus,代码行数:20,代码来源:BigqueryFactory.java

示例3: FirebaseChannel

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
/**
 * Construct the singleton, with derived auth information. The Firebase database url is derived
 * from the snippet that we provide to the client code, to guarantee that the client and the
 * server are communicating with the same Firebase database. The auth credentials we'll use to
 * communicate with Firebase is derived from App Engine's default credentials, and given
 * Firebase's OAuth scopes.
 */
private FirebaseChannel(ServletContext servletContext) {
  try {
    // This variables exist primarily so it can be stubbed out in unit tests.
    if (null == firebaseConfigStream) {
      Preconditions.checkNotNull(servletContext,
          "Servlet context expected to initialize Firebase channel");
      firebaseConfigStream = servletContext.getResourceAsStream(FIREBASE_SNIPPET_PATH);
    }

    String firebaseSnippet = CharStreams.toString(new InputStreamReader(
        firebaseConfigStream, StandardCharsets.UTF_8));
    firebaseDbUrl = parseFirebaseUrl(firebaseSnippet);

    credential = GoogleCredential.getApplicationDefault().createScoped(FIREBASE_SCOPES);
    httpTransport = UrlFetchTransport.getDefaultInstance();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:27,代码来源:FirebaseChannel.java

示例4: FirebaseChannel

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
/**
 * Construct the singleton, with derived auth information. The Firebase database url is derived
 * from the snippet that we provide to the client code, to guarantee that the client and the
 * server are communicating with the same Firebase database. The auth credentials we'll use to
 * communicate with Firebase is derived from App Engine's default credentials, and given
 * Firebase's OAuth scopes.
 */
private FirebaseChannel() {
  try {
    // This variables exist primarily so it can be stubbed out in unit tests.
    if (null == firebaseConfigStream) {
      firebaseConfigStream = new FileInputStream(FIREBASE_SNIPPET_PATH);
    }

    String firebaseSnippet =
        CharStreams.toString(new InputStreamReader(firebaseConfigStream, StandardCharsets.UTF_8));
    firebaseDbUrl = parseFirebaseUrl(firebaseSnippet);

    credential = GoogleCredential.getApplicationDefault().createScoped(FIREBASE_SCOPES);
    httpTransport = UrlFetchTransport.getDefaultInstance();
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:25,代码来源:FirebaseChannel.java

示例5: FirebaseChannelDelegator

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
/**
 * Construct the singleton, with derived auth information. The Firebase database url is derived
 * from the snippet that we provide to the client code, to guarantee that the client and the
 * server are communicating with the same Firebase database. The auth credentials we'll use to
 * communicate with Firebase is derived from App Engine's default credentials, and given
 * Firebase's OAuth scopes.
 */
public FirebaseChannelDelegator() {
    super();

    try {
        // This variables exist primarily so it can be stubbed out in unit tests.
        if (null == firebaseConfigStream) {
            firebaseConfigStream = new FileInputStream(FIREBASE_SNIPPET_PATH);
        }

        String firebaseSnippet = CharStreams.toString(new InputStreamReader(
                firebaseConfigStream, StandardCharsets.UTF_8));
        firebaseDbUrl = parseFirebaseUrl(firebaseSnippet);

        credential = GoogleCredential.getApplicationDefault().createScoped(FIREBASE_SCOPES);
        httpTransport = UrlFetchTransport.getDefaultInstance();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:WELTEN,项目名称:dojo-ibl,代码行数:27,代码来源:FirebaseChannelDelegator.java

示例6: initialise

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
@Override
public void initialise(UpdatableInjectionContext injectionContext) {
    super.initialise(injectionContext);

    // for gmail API as the setup stores the creds established at setup time in DS
    injectionContext.inject(AppEngineDataStoreFactory.getDefaultInstance()).as(DataStoreFactory.class);
    injectionContext.inject(UrlFetchTransport.getDefaultInstance()).as(HttpTransport.class);

    Class<? extends Mailer> mailerClass = Environment.is(Environment.DEV) ? LoggingMailer.class : GmailMailer.class;
    injectionContext.inject(mailerClass).as(Mailer.class);
}
 
开发者ID:3wks,项目名称:generator-thundr-gae-react,代码行数:12,代码来源:UserManagerModule.java

示例7: createClient

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Client createClient(String configServiceName)
    throws GeneralSecurityException, IOException {
  return new Client.Builder(configServiceName)
      .setStatsLogFrequency(statsLogFrequency())
      .setHttpTransport(UrlFetchTransport.getDefaultInstance())
      .setFactory(ThreadManager.backgroundThreadFactory())
      .build();
}
 
开发者ID:cloudendpoints,项目名称:endpoints-management-java,代码行数:13,代码来源:GoogleAppEngineControlFilter.java

示例8: doGet

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws IOException {
	resp.setContentType("text/plain");
	resp.getWriter().println("Hello, world");
			
	HttpTransport httpTransport = new UrlFetchTransport();        
	JacksonFactory jsonFactory = new JacksonFactory();

	/*
	AppIdentityService appIdentity = AppIdentityServiceFactory.getAppIdentityService();    
	AppIdentityService.GetAccessTokenResult accessToken = appIdentity.getAccessToken(Arrays.asList(Oauth2Scopes.USERINFO_EMAIL));         
	GoogleCredential credential = new GoogleCredential.Builder()
		.setTransport(httpTransport)
		.setJsonFactory(jsonFactory).build();
    credential.setAccessToken(accessToken.getAccessToken());
	*/

	GoogleCredential credential = GoogleCredential.getApplicationDefault(httpTransport,jsonFactory);    
	if (credential.createScopedRequired())
	    credential = credential.createScoped(Arrays.asList(Oauth2Scopes.USERINFO_EMAIL));           

	Oauth2 service = new Oauth2.Builder(httpTransport, jsonFactory, credential)
	    .setApplicationName("oauth client").build();

	Userinfoplus ui = service.userinfo().get().execute(); 
	resp.getWriter().println(ui.getEmail());
    

         // Using Google Cloud APIs
	  Storage  storage_service = StorageOptions.defaultInstance().service();
       
         Iterator<Bucket> bucketIterator = storage_service.list().iterateAll();
         while (bucketIterator.hasNext()) {
           System.out.println(bucketIterator.next());
         }		

}
 
开发者ID:salrashid123,项目名称:gcpsamples,代码行数:38,代码来源:TestServlet.java

示例9: provideBigquery

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
/** Provides the authenticated Bigquery API object. */
@Provides
@Singleton
Bigquery provideBigquery() {
  return new Bigquery.Builder(
      new UrlFetchTransport(),
      new JacksonFactory(),
      new AppIdentityCredential(BigqueryScopes.all()))
          .setApplicationName(BigQueryModule.class.getName())
          .build();
}
 
开发者ID:google,项目名称:domaintest,代码行数:12,代码来源:BigQueryModule.java

示例10: getMirror

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
private Mirror getMirror(HttpServletRequest req) throws IOException{
	Credential credential = AuthUtil.getCredential(req);

	// build access to Mirror API
	return new Mirror.Builder(
			new UrlFetchTransport(), new JacksonFactory(), credential)
				.setApplicationName("Hello World").build();
}
 
开发者ID:ipool,项目名称:GlassPool,代码行数:9,代码来源:IpoolAPIClient.java

示例11: getMirror

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
public static Mirror getMirror( Credential credential )
    throws IOException
{
  return new Mirror.Builder(
      new UrlFetchTransport(),
      new JacksonFactory(),
      credential)
  .setApplicationName("Lunch Roulette")
  .build();
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:11,代码来源:MirrorUtils.java

示例12: getMirror

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
public static Mirror getMirror( Credential credential )
    throws IOException
{
  return new Mirror.Builder(
      new UrlFetchTransport(),
      new JacksonFactory(),
      credential)
  .setApplicationName("ChittrChattr")
  .build();
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:11,代码来源:MirrorUtils.java

示例13: buildCodeFlow

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
/**
 * Gets the credentials stored in GAE. If expired, uses the refresh token to
 * get a new access token from OAuth
 * @return
 * @throws IOException
 */
public static AuthorizationCodeFlow buildCodeFlow()
    throws IOException
{
  return new GoogleAuthorizationCodeFlow.Builder(
      new UrlFetchTransport(),
      new JacksonFactory(),
      WEB_CLIENT_ID,
      WEB_CLIENT_SECRET,
      SCOPES)
  .setApprovalPrompt( "force" )
  .setAccessType("offline")
  .setCredentialDataStore( getDataStore() )
  .build();
}
 
开发者ID:coderoshi,项目名称:glass,代码行数:21,代码来源:AuthUtils.java

示例14: OauthRawGcsService

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
OauthRawGcsService(OAuthURLFetchService urlfetch, ImmutableSet<HTTPHeader> headers) {
  this.urlfetch = checkNotNull(urlfetch, "Null urlfetch");
  this.headers = checkNotNull(headers, "Null headers");
  AppIdentityCredential cred = new AppIdentityCredential(OAUTH_SCOPES);
  storage = new Storage.Builder(new UrlFetchTransport(), new JacksonFactory(), cred)
      .setApplicationName(SystemProperty.applicationId.get()).build();
}
 
开发者ID:GoogleCloudPlatform,项目名称:appengine-gcs-client,代码行数:8,代码来源:OauthRawGcsService.java

示例15: initializeFlow

import com.google.api.client.extensions.appengine.http.UrlFetchTransport; //导入依赖的package包/类
@Override
protected AuthorizationCodeFlow initializeFlow() throws IOException {
	return new GoogleAuthorizationCodeFlow.Builder(new UrlFetchTransport(),
			jsonFactory, "610309933249.apps.googleusercontent.com",
			"YDq0zPizR0rJANUBlgbzlb_4", CredentialManager.SCOPES)
			.setCredentialStore(credentialStore)
			.setAccessType("offline")
			.build();
}
 
开发者ID:aleksz,项目名称:driveddoc,代码行数:10,代码来源:AuthorizationServlet.java


注:本文中的com.google.api.client.extensions.appengine.http.UrlFetchTransport类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。