• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AppIdentityCredential类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的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


示例2: provideDataflow

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的package包/类
/** Constructs a {@link Dataflow} API client with default settings. */
@Provides
static Dataflow provideDataflow(
    @Config("projectId") String projectId,
    HttpTransport transport,
    JsonFactory jsonFactory,
    Function<Set<String>, AppIdentityCredential> appIdentityCredentialFunc) {

  return new Dataflow.Builder(
          transport,
          jsonFactory,
          appIdentityCredentialFunc.apply(ImmutableSet.of(CLOUD_PLATFORM_SCOPE)))
      .setApplicationName(String.format("%s billing", projectId))
      .build();
}
 
开发者ID:google,项目名称:nomulus,代码行数:16,代码来源:BillingModule.java


示例3: provideBigquery

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的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


示例4: doGet

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的package包/类
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {

  try {
    AppIdentityCredential credential = new AppIdentityCredential(Arrays.asList(STORAGE_SCOPE));

    // Set up and execute Google Cloud Storage request.
    String bucketName = req.getRequestURI();
    if (bucketName.equals("/")) {
      resp.sendError(404, "No bucket specified - append /bucket-name to the URL and retry.");
      return;
    }
    // Remove any trailing slashes, if found.
    //[START snippet]
    String cleanBucketName = bucketName.replaceAll("/$", "");
    String URI = GCS_URI + cleanBucketName;
    HttpRequestFactory requestFactory = HTTP_TRANSPORT.createRequestFactory(credential);
    GenericUrl url = new GenericUrl(URI);
    HttpRequest request = requestFactory.buildGetRequest(url);
    HttpResponse response = request.execute();
    String content = response.parseAsString();
    //[END snippet]

    // Display the output XML.
    resp.setContentType("text/xml");
    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(resp.getOutputStream()));
    String formattedContent = content.replaceAll("(<ListBucketResult)", XSL + "$1");
    writer.append(formattedContent);
    writer.flush();
    resp.setStatus(200);
  } catch (Throwable e) {
    resp.sendError(404, e.getMessage());
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:cloud-storage-docs-xml-api-examples,代码行数:35,代码来源:StorageSample.java


示例5: OauthRawGcsService

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的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


示例6: getUrlShortener

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的package包/类
public static Urlshortener getUrlShortener() {
    AppIdentityCredential credential = new AppIdentityCredential(Arrays.asList(UrlshortenerScopes.URLSHORTENER));
    return new Urlshortener.Builder(new UrlFetchTransport(), new JacksonFactory(), credential)
            .setApplicationName("Tracking API")
            .build();
}
 
开发者ID:Steppschuh,项目名称:PlaceTracking,代码行数:7,代码来源:GoogleUrlShortener.java


示例7: provideAppIdentityCredential

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的package包/类
@Provides
static Function<Set<String>, AppIdentityCredential> provideAppIdentityCredential() {
  return AppIdentityCredential::new;
}
 
开发者ID:google,项目名称:nomulus,代码行数:5,代码来源:Modules.java


示例8: provideHttpRequestInitializer

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的package包/类
@Binds
abstract Function<Set<String>, ? extends HttpRequestInitializer> provideHttpRequestInitializer(
    Function<Set<String>, AppIdentityCredential> credential);
 
开发者ID:google,项目名称:nomulus,代码行数:4,代码来源:Modules.java


示例9: doGet

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的package包/类
@Override
protected void doGet(
    final HttpServletRequest req, final HttpServletResponse resp)
throws IOException {

  try {
    AppIdentityCredential credential = new AppIdentityCredential(
        Arrays.asList(STORAGE_SCOPE));

    // Set up and execute Google Cloud Storage request.
    String bucketName = req.getRequestURI();
    if (bucketName.equals("/")) {
      resp.sendError(
          HTTP_NOT_FOUND,
          "No bucket specified - append /bucket-name to the URL and retry.");
      return;
    }
    // Remove any trailing slashes, if found.
    //[START snippet]
    String cleanBucketName = bucketName.replaceAll("/$", "");
    String uri = GCS_URI + cleanBucketName;
    HttpRequestFactory requestFactory =
        HTTP_TRANSPORT.createRequestFactory(credential);
    GenericUrl url = new GenericUrl(uri);
    HttpRequest request = requestFactory.buildGetRequest(url);
    HttpResponse response = request.execute();
    String content = response.parseAsString();
    //[END snippet]

    // Display the output XML.
    resp.setContentType("text/xml");
    BufferedWriter writer = new BufferedWriter(
        new OutputStreamWriter(resp.getOutputStream()));
    String formattedContent = content.replaceAll(
        "(<ListBucketResult)", XSL + "$1");
    writer.append(formattedContent);
    writer.flush();
    resp.setStatus(HTTP_OK);
  } catch (Throwable e) {
    resp.sendError(HTTP_NOT_FOUND, e.getMessage());
  }
}
 
开发者ID:GoogleCloudPlatform,项目名称:java-docs-samples,代码行数:43,代码来源:StorageSample.java


示例10: doGet

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的package包/类
public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
	resp.setContentType("text/plain");
	
	AppIdentityCredential credential = new AppIdentityCredential(AnalysisConstants.SCOPES);
	
	String bigqueryProjectId = AnalysisUtility.extractParameterOrThrow(req, AnalysisConstants.BIGQUERY_PROJECT_ID_PARAM);
	String jobId = AnalysisUtility.extractParameterOrThrow(req, AnalysisConstants.BIGQUERY_JOB_ID_PARAM);
	String queueName = AnalysisUtility.extractParameterOrThrow(req, AnalysisConstants.QUEUE_NAME_PARAM);

	Bigquery bigquery = Bigquery.builder(HTTP_TRANSPORT, JSON_FACTORY)
			.setHttpRequestInitializer(credential)
			.setApplicationName("Streak Logs")
			.build();
	
	Job j = bigquery.jobs().get(bigqueryProjectId, jobId).execute();
	j.getConfiguration().getLoad().getSourceUris();
	
	
	if ("DONE".equals(j.getStatus().getState())) {
	
		FileService fs = FileServiceFactory.getFileService();
		List<AppEngineFile> filesForJob = new ArrayList<AppEngineFile>();
		for (String f : j.getConfiguration().getLoad().getSourceUris()) {
			if (f.contains("gs://")) {
				String filename = f.replace("gs://", "/gs/");
				AppEngineFile file = new AppEngineFile(filename);
				filesForJob.add(file);
				
				resp.getWriter().println("Deleting: " + f + ", appengine filename: " + filename);
			}
		}
		
		fs.delete(filesForJob.toArray(new AppEngineFile[0]));
	}
	else {
		resp.getWriter().println("Status was not DONE, it was " + j.getStatus().getState());
		
		// check again in 5 mins if the job is done
		String retryCountStr = req.getParameter(AnalysisConstants.RETRY_COUNT_PARAM);
		int retryCount = -1;
		if (AnalysisUtility.areParametersValid(retryCountStr)) {
			retryCount = Integer.parseInt(retryCountStr);
		}
		retryCount++;
		
		if (retryCount > 15) {
			resp.getWriter().println("Tried too many times to find job, aborting");
		}
		
		Queue taskQueue = QueueFactory.getQueue(queueName);
		taskQueue.add(
				Builder.withUrl(
						AnalysisUtility.getRequestBaseName(req) + "/deleteCompletedCloudStorageFilesTask")
					   .method(Method.GET)
					   .param(AnalysisConstants.BIGQUERY_JOB_ID_PARAM, jobId)
					   .param(AnalysisConstants.QUEUE_NAME_PARAM, queueName)
					   .param(AnalysisConstants.RETRY_COUNT_PARAM, String.valueOf(retryCount))
					   .etaMillis(System.currentTimeMillis() + 5 * 60 * 1000)
					   .param(AnalysisConstants.BIGQUERY_PROJECT_ID_PARAM, bigqueryProjectId));
	
	}
	
}
 
开发者ID:steveseo,项目名称:l2bq,代码行数:64,代码来源:DeleteCompletedCloudStorageFilesTask.java


示例11: makeCalendarServiceInstance

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的package包/类
/**
 * 
 * @return Calendar service object
 * @throws GeneralSecurityException
 * @throws IOException
 */
public static Calendar makeCalendarServiceInstance() {

	AppIdentityCredential credential = makeServiceAccountCredential();

	Calendar service = new Calendar.Builder(TRANSPORT, FACTORY, credential).setApplicationName("Zeppa").build();

	return service;
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:15,代码来源:GoogleCalendarUtils.java


示例12: makeServiceAccountCredential

import com.google.api.client.googleapis.extensions.appengine.auth.oauth2.AppIdentityCredential; //导入依赖的package包/类
/**
 * Generates a new Google Credential for the service account
 * 
 * @param httpTransport
 * @param jsonFactory
 * @return
 * @throws IOException
 * @throws GeneralSecurityException
 */
private static AppIdentityCredential makeServiceAccountCredential() {

	AppIdentityCredential credential = new AppIdentityCredential(SCOPES);
	return credential;
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:15,代码来源:GoogleCalendarUtils.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ForwardedRequestCustomizer类代码示例发布时间:2022-05-22
下一篇:
Java Yaml类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap