2016-11-03 5 views
0

を認証するためのデフォルトの資格情報 "の背後にあるロジックは、私はたBigQuery JavaクライアントにたBigQueryクライアント

/** 
* Creates an authorized Bigquery client service using Application Default Credentials. 
* 
* @return an authorized Bigquery client 
* @throws IOException if there's an error getting the default credentials. 
*/ 
public static Bigquery createAuthorizedClient() throws IOException { 
    // Create the credential 
    HttpTransport transport = new NetHttpTransport(); 
    JsonFactory jsonFactory = new JacksonFactory(); 
    GoogleCredential credential = GoogleCredential.getApplicationDefault(transport, jsonFactory); 

    // Depending on the environment that provides the default credentials (e.g. Compute Engine, App 
    // Engine), the credentials may require us to specify the scopes we need explicitly. 
    // Check for this case, and inject the Bigquery scope if required. 
    if (credential.createScopedRequired()) { 
     credential = credential.createScoped(BigqueryScopes.all()); 
    } 

    return new Bigquery.Builder(transport, jsonFactory, credential) 
      .setApplicationName("Bigquery Samples") 
      .build(); 
} 

を認証する2つの方法を見て、この

public class QuickstartSample { 

    public static void Main() { 

     // Your Google Cloud Platform project ID 
     string projectId = "YOUR_PROJECT_ID"; 

     // Instantiates a client 
     BigqueryClient client = BigqueryClient.Create(projectId); 

     // The id for the new dataset 
     string datasetId = "my_new_dataset"; 

     // Creates the dataset 
     BigqueryDataset dataset = client.CreateDataset(datasetId); 

     Console.WriteLine($"Dataset {dataset.FullyQualifiedId} created."); 
    } 
} 

何これは何を意味するのでしょうか?

default credentials (e.g. Compute Engine, App Engine)

右、私の特定のGCPプロジェクトにアクセスすることはできないのだろうか?

この点はどういう意味ですかdefault credentials

答えて

関連する問題