Java Code Examples for com.google.api.client.googleapis.util.Utils#getDefaultTransport()

The following examples show how to use com.google.api.client.googleapis.util.Utils#getDefaultTransport() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoogleIdTokenAuth.java    From styx with Apache License 2.0 5 votes vote down vote up
static GoogleIdTokenAuth ofDefaultCredential() {
  try {
    return new GoogleIdTokenAuth(Utils.getDefaultTransport(),
        Optional.of(GoogleCredentials.getApplicationDefault()));
  } catch (IOException e) {
    return of(Optional.empty());
  }
}
 
Example 2
Source File: GoogleIdTokenVerifierTest.java    From styx with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
  final var keyGen = KeyPairGenerator.getInstance("RSA");
  keyGen.initialize(571);
  KeyPair pair = keyGen.generateKeyPair();
  privateKey = pair.getPrivate();

  final var keysManager = new GooglePublicKeysManager(Utils.getDefaultTransport(), Utils.getDefaultJsonFactory());
  stubPublicKey(keysManager, pair.getPublic());

  verifier = new GoogleIdTokenVerifier(keysManager);
}
 
Example 3
Source File: GoogleCredentialsBundle.java    From nomulus with Apache License 2.0 5 votes vote down vote up
private GoogleCredentialsBundle(GoogleCredentials googleCredentials) {
  checkNotNull(googleCredentials);
  this.googleCredentials = googleCredentials;
  this.httpTransport = Utils.getDefaultTransport();
  this.jsonFactory = Utils.getDefaultJsonFactory();
  this.httpRequestInitializer = new HttpCredentialsAdapter(googleCredentials);
}
 
Example 4
Source File: ManagedServiceAccountKeyCredential.java    From styx with Apache License 2.0 4 votes vote down vote up
private TokenResponse requestToken(String signedJwt) throws IOException {
  var tokenRequest = new TokenRequest(Utils.getDefaultTransport(), Utils.getDefaultJsonFactory(),
      new GenericUrl(getTokenServerEncodedUrl()), "urn:ietf:params:oauth:grant-type:jwt-bearer");
  tokenRequest.put("assertion", signedJwt);
  return tokenRequest.execute();
}
 
Example 5
Source File: GCSOptions.java    From dataflow-java with Apache License 2.0 4 votes vote down vote up
@Override
public HttpTransport create(PipelineOptions options) {
  return Utils.getDefaultTransport();
}
 
Example 6
Source File: TransferClientCreator.java    From java-docs-samples with Apache License 2.0 3 votes vote down vote up
/**
 * Create a Storage Transfer client using application default credentials and other default
 * settings.
 *
 * @return a Storage Transfer client
 * @throws IOException there was an error obtaining application default credentials
 */
public static Storagetransfer createStorageTransferClient() throws IOException {
  HttpTransport httpTransport = Utils.getDefaultTransport();
  JsonFactory jsonFactory = Utils.getDefaultJsonFactory();
  GoogleCredentials credential = GoogleCredentials.getApplicationDefault();
  return createStorageTransferClient(httpTransport, jsonFactory, credential);
}