GCP Dialogflow Java-SpringBoot authentication - Application Default Credentials are not available

I need to connect to GCP Dialogflow for detecting intents. I'm using SpringBoot with Java to connect to Dialogflow. This application runs in Pivotal Cloud Foundry (PCF) and I don't know how GOOGLE_APPLICATION_CREDENTIALS environment variable can be set there.

All suggested solutions here use either gcloud, Google SDK or the app runs in Google Compute Engine. These solutions don't work for my architecture.

GoogleCredentials is always null even if it is set as suggested below -

GoogleCredentials.fromStream(new FileStream("creds.json"));


GoogleCredentials creds = null;
try {
    creds = GoogleCredentials.fromStream(new FileInputStream("creds.json"));
} catch (Exception e) {

Error -

java.io.IOException: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials...

1 answer