GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — java-docs-samples/auth at main · Reality2byte/java-docs-samples

Expand file tree

/

auth

/
Copy path

Directory actions

More options

More options

Directory actions

More options

More options

Latest commit

 

History

History
History
 
 
/

auth

/
Copy path

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
src
src
 
 
.gitignore
.gitignore
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

README.md

Outline

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.

This section provides examples for Downscoping with Credential Access Boundaries. There are two examples demonstrating different ways to implement downscoping.

DownscopedAccessTokenGenerator and DownscopedAccessTokenConsumer Examples:

These examples demonstrate a common pattern for downscoping, using a token broker and consumer. The DownscopedAccessTokenGenerator generates the downscoped access token using a client-side approach, and the DownscopedAccessTokenConsumer uses it to access Cloud Storage resources. To run the DownscopedAccessTokenConsumer, you must provide a bucket name and object name under the TODO(developer): in the main method. You can then run DownscopedAccessTokenConsumer via:

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

DownscopingExample Example:

This example demonstrates downscoping using a server-side approach. To run this example 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
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.