本文整理汇总了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();
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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();
}
示例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());
}
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}