Skip to content

Latest commit

 

History

History
 
 

auth

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Getting Started with Google Cloud Authentication

Open in Cloud Shell

See the documentation for more information about authenticating for Google Cloud APIs.

Quickstart

Install Maven.

Build your project with:

mvn clean package -DskipTests

You can then run a given ClassName via:

mvn exec:java -Dexec.mainClass=com.example.storage.ClassName \
    -DpropertyName=propertyValue \
	-Dexec.args="any arguments to the app"

Listing buckets with default credentials

mvn exec:java -Dexec.mainClass=com.google.cloud.auth.samples.AuthExample

Listing buckets with credentials in json file

mvn exec:java -Dexec.mainClass=com.google.cloud.auth.samples.AuthExample
    -Dexec.args="explicit [path-to-credentials-json]"

Listing buckets while running on a Google Compute Engine instance

mvn exec:java -Dexec.mainClass=com.google.cloud.auth.samples.AuthExample
    -Dexec.args="compute"

Analyze text sentiment using LanguageService API with API key authentication

Create an API key via the Google Cloud console:

Once you have an API key replace it in the main function in ApiKeyAuthExample and run the following command

mvn exec:java -Dexec.mainClass=com.google.cloud.auth.samples.ApiKeyAuthExample

Downscoping with Credential Access Boundaries

The same configuration above applies.

To run the samples for Downscoping with Credential Access Boundaries you must provide both a bucket name and object name under the TODO(developer): in the main method of DownscopingExample.

You can then run DownscopingExample via:

mvn exec:java -Dexec.mainClass=com.google.cloud.auth.samples.DownscopingExample

Tests

Run all tests:

   mvn clean verify