本文整理汇总了Java中com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractGoogleJsonClient.Builder方法的具体用法?Java AbstractGoogleJsonClient.Builder怎么用?Java AbstractGoogleJsonClient.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient
的用法示例。
在下文中一共展示了AbstractGoogleJsonClient.Builder方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareBuilder
import com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient; //导入方法依赖的package包/类
private <T extends AbstractGoogleJsonClient.Builder> T prepareBuilder(T builder,
final HttpRequestInitializer delegate,
GoogleClientRequestInitializer googleClientRequestInitializer) {
builder
.setHttpRequestInitializer(getHttpRequestInitializer(delegate))
.setApplicationName(applicationName)
.setGoogleClientRequestInitializer(googleClientRequestInitializer);
if (rootUrl.isPresent()) {
builder.setRootUrl(rootUrl.get());
}
if (servicePath.isPresent()) {
builder.setServicePath(servicePath.get());
}
return builder;
}
示例2: setupLocalApi
import com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient; //导入方法依赖的package包/类
private void setupLocalApi(AbstractGoogleJsonClient.Builder builder) {
builder.setApplicationName(appName)
.setRootUrl(rootUrl)
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
@Override
public void initialize(AbstractGoogleClientRequest<?> request) throws IOException {
request.setDisableGZipContent(true);
}
});
}
示例3: updateCredential
import com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient; //导入方法依赖的package包/类
public static AbstractGoogleJsonClient updateCredential(AbstractGoogleJsonClient.Builder builder, String accountName) {
GoogleAccountCredential credential = (GoogleAccountCredential) builder.getHttpRequestInitializer();
String selectedAccountName = credential.getSelectedAccountName();
if (selectedAccountName == null || !selectedAccountName.equals(accountName)) {
credential.setSelectedAccountName(accountName);
builder.setHttpRequestInitializer(credential);
}
return builder.build();
}
示例4: fromClientSecretsFile
import com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient; //导入方法依赖的package包/类
/**
* Prepare an AbstractGoogleJsonClient.Builder using a {@code client_secrets.json} {@link File}.
*
* @param builder The builder to be prepared.
* @param clientSecretsJson {@code client_secrets.json} file.
* @return The passed in builder, for easy chaining.
*/
public <T extends AbstractGoogleJsonClient.Builder> T fromClientSecretsFile(T builder,
File clientSecretsJson) {
Preconditions.checkNotNull(builder);
Preconditions.checkNotNull(clientSecretsJson);
return prepareBuilder(builder,
CredentialFactory.getCredentialFromClientSecrets(clientSecretsJson.getAbsolutePath(),
applicationName),
null);
}
示例5: fromServiceAccount
import com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient; //导入方法依赖的package包/类
/**
* Prepare an AbstractGoogleJsonClient.Builder with the given service account ID
* and private key {@link File}.
*
* @param builder The builder to be prepared.
* @param serviceAccountId The service account ID (typically an email address)
* @param p12File The file on disk containing the private key
* @return The passed in builder, for easy chaining.
* @throws GeneralSecurityException
* @throws IOException
*/
public <T extends AbstractGoogleJsonClient.Builder> T fromServiceAccount(T builder,
String serviceAccountId, File p12File) throws GeneralSecurityException, IOException {
Preconditions.checkNotNull(builder);
GoogleCredential creds = new GoogleCredential.Builder()
.setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(serviceAccountId)
.setServiceAccountScopes(scopes)
.setServiceAccountPrivateKeyFromP12File(p12File)
.build();
creds.refreshToken();
return prepareBuilder(builder, creds, null);
}
示例6: fromOfflineAuth
import com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient; //导入方法依赖的package包/类
/**
* Prepare an AbstractGoogleJsonClient.Builder with the given OfflineAuth object.
*
* @param builder The builder to be prepared.
* @param auth The OfflineAuth
* @return The passed in builder, for easy chaining.
*/
public <T extends AbstractGoogleJsonClient.Builder> T fromOfflineAuth(T builder, OfflineAuth auth) {
Preconditions.checkNotNull(builder);
Preconditions.checkNotNull(auth);
if(auth.hasApiKey()) {
return fromApiKey(builder, auth.getApiKey());
}
return fromCredential(builder, auth.getCredential());
}
示例7: fromApiKey
import com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient; //导入方法依赖的package包/类
/**
* Prepare an AbstractGoogleJsonClient.Builder using an API key.
*
* @param builder The builder to be prepared.
* @param apiKey The API key of the Google Cloud Platform project.
* @return The passed in builder, for easy chaining.
*/
public <T extends AbstractGoogleJsonClient.Builder> T fromApiKey(T builder, String apiKey) {
Preconditions.checkNotNull(builder);
Preconditions.checkNotNull(apiKey);
return prepareBuilder(builder, null, new CommonGoogleClientRequestInitializer(apiKey));
}
示例8: fromCredential
import com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient; //导入方法依赖的package包/类
/**
* Prepare an AbstractGoogleJsonClient.Builder using a credential.
*
* @param builder The builder to be prepared.
* @param credential The credential to be used for requests.
* @return The passed in builder, for easy chaining.
*/
public <T extends AbstractGoogleJsonClient.Builder> T fromCredential(T builder, Credential credential) {
Preconditions.checkNotNull(builder);
Preconditions.checkNotNull(credential);
return prepareBuilder(builder, credential, null);
}
示例9: fromApplicationDefaultCredential
import com.google.api.client.googleapis.services.json.AbstractGoogleJsonClient; //导入方法依赖的package包/类
/**
* Prepare an AbstractGoogleJsonClient.Builder using the Application Default Credential.
*
* @param builder The builder to be prepared.
* @return The passed in builder, for easy chaining.
*/
public <T extends AbstractGoogleJsonClient.Builder> T fromApplicationDefaultCredential(T builder) {
Preconditions.checkNotNull(builder);
return fromCredential(builder, CredentialFactory.getApplicationDefaultCredential());
}