Example usage for com.google.api.client.googleapis.compute ComputeCredential ComputeCredential

List of usage examples for com.google.api.client.googleapis.compute ComputeCredential ComputeCredential

Introduction

In this page you can find the example usage for com.google.api.client.googleapis.compute ComputeCredential ComputeCredential.

Prototype

public ComputeCredential(HttpTransport transport, JsonFactory jsonFactory) 

Source Link

Usage

From source file:com.google.gcloud.AuthConfig.java

License:Open Source License

static ComputeCredential getComputeCredential() throws IOException, GeneralSecurityException {
    NetHttpTransport transport = GoogleNetHttpTransport.newTrustedTransport();
    // Try to connect using Google Compute Engine service account credentials.
    ComputeCredential credential = new ComputeCredential(transport, new JacksonFactory());
    // Force token refresh to detect if we are running on Google Compute Engine.
    credential.refreshToken();/*from   www.j  ava 2 s .c  o  m*/
    return credential;
}

From source file:com.google.jenkins.plugins.credentials.oauth.GoogleRobotMetadataCredentials.java

License:Open Source License

/**
 * {@inheritDoc}/*  w  w  w  .  j a va  2  s  .co  m*/
 */
@Override
public ComputeCredential getGoogleCredential(GoogleOAuth2ScopeRequirement requirement)
        throws GeneralSecurityException {
    // Ideally GCE would allow us to down-scope the metadata credentials we are
    // providing a given library.
    return new ComputeCredential(getModule().getHttpTransport(), getModule().getJsonFactory());
}