Google Cloud Programmatic Access from Java: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 27: Line 27:
The service account can be created, if it does not exist already, with <code>[[Google_Cloud_Identity_and_Access_Management_Operations#Create_Service_Account|gcloud iam service-accounts create]]</code>. The service account can then be granted permissions on resource with <code>[[Google_Cloud_Identity_and_Access_Management_Operations#Give_Service_Account_Permissions_on_a_Project|gcloud projects add-iam-policy-binding]]</code>. A key file for the service account can be generated with <code>[[Google_Cloud_Identity_and_Access_Management_Operations#Generate_a_Key_File_for_Service_Account|gcloud iam service-accounts keys create]]</code>.
The service account can be created, if it does not exist already, with <code>[[Google_Cloud_Identity_and_Access_Management_Operations#Create_Service_Account|gcloud iam service-accounts create]]</code>. The service account can then be granted permissions on resource with <code>[[Google_Cloud_Identity_and_Access_Management_Operations#Give_Service_Account_Permissions_on_a_Project|gcloud projects add-iam-policy-binding]]</code>. A key file for the service account can be generated with <code>[[Google_Cloud_Identity_and_Access_Management_Operations#Generate_a_Key_File_for_Service_Account|gcloud iam service-accounts keys create]]</code>.


Once the service account key file exists, the programmatic client is configured with the key file by setting the <code></code> environment variable:
Once the service account [[Google_Cloud_Identity_and_Access_Management_Concepts#Service_Account_Key_File|key file exists]], the programmatic client is configured with the key file by setting the <code></code> environment variable:
<syntaxhighlight lang='bash'>
<syntaxhighlight lang='bash'>
</syntaxhighlight>
</syntaxhighlight>

Revision as of 00:07, 25 August 2021

External

Internal

Overview

Service-Specific Libraries

Supported Java Versions

https://cloud.google.com/java/docs/supported-java-versions

Gradle

repositories {
    mavenCentral()
}

dependencies {
    implementation platform('com.google.cloud:libraries-bom:21.0.0')
    implementation 'com.google.cloud:google-cloud-storage'
}

Client Authentication

The programmatic client needs to assume the identity of an already existing service account that has sufficient permissions to access the desired resource.

The service account can be created, if it does not exist already, with gcloud iam service-accounts create. The service account can then be granted permissions on resource with gcloud projects add-iam-policy-binding. A key file for the service account can be generated with gcloud iam service-accounts keys create.

Once the service account key file exists, the programmatic client is configured with the key file by setting the environment variable: