How to Connect to GCP Services without Using JSON file in Java

Viewed 34

I am Trying to connect to GCP PUSUB Services using IAM authentication. I want to do this without the .json file.

I tried using

GoogleCredentials credential = GoogleCredentials.getApplicationDefault(() -> httpTransport);

But this is too required application_default_credentials.json file to get Authenticated .

Basically , I want to get Authorized using GCP IAM API to use GCP PUBSUB Services .

Plan - I Want to run a sample Java code from my local , connecting to GCP PUBSUB instance and test and after testing , Deploying the same at GCP container and then test the same PUBSUB.

to Connect to GCP PUBSUB instance from my local system I want to do that Via IAM Authentication mechanism .

Any reference ? Please help

thanks

1 Answers

Application default credentials can be setup with gcloud CLI. Once you install gcloud, gcloud auth application-default login will allow all the client libraries and Spring Cloud GCP modules to get your credentials from the environment.

Related