google-api-java-client-services icon indicating copy to clipboard operation
google-api-java-client-services copied to clipboard

Question: No JSON input found error message is displayed, if the Service account Key file is placed at external location

Open shrgupta28 opened this issue 5 years ago • 4 comments

Hi Team,

For a Java project, if the Service Account key connection .json file is placed at an external location or at subfolder under the project root, No JSON Input found error message is displayed during runtime.

If the .json file is placed at the root level, the project runs without any issues.

Can you please help me with this. If there is any restriction from bigquery about this. Or what is the right way of doing it?

Thanks, Shruti

shrgupta28 avatar May 21 '20 09:05 shrgupta28

@danoscarmike @pmakani Request your help on this.

shrgupta28 avatar Jun 09 '20 06:06 shrgupta28

Which client are you trying to use for authentication? Also a code snippet of what you are attempting to do would help.

chingor13 avatar Jun 09 '20 07:06 chingor13

Hi @chingor13

We have recently migrated to https://github.com/googleapis/java-bigquery

PFB the sample code snippet.

public static BigQuery explicit() throws IOException {
		// TODO(developer): Replace these variables before running the sample.
		String projectId = "projectId";
		String jsonFilePath = "JSON_FILE_PATH.json";		

		InputStream is = null; 

		if(jsonFilePath != null && !jsonFilePath.isEmpty()){
			is = new FileInputStream(jsonFilePath);
		}

		GoogleCredentials credentials = ServiceAccountCredentials.fromStream(is);

		BigQuery bigquery = BigQueryOptions.newBuilder().setCredentials(credentials).setProjectId(projectId).build().getService();

		return bigquery;

	}

shrgupta28 avatar Jun 11 '20 10:06 shrgupta28

hi @chingor13 Any updates on this issue?

shrgupta28 avatar Jun 22 '20 10:06 shrgupta28

Closing this issue as we are unable to provide adequate customer support through this forum. If you feel there is a bug or a feature request associated with this ticket, please open a new issue. Otherwise, https://cloud.google.com/support is best able to provide timely answers to API-specific questions.

burkedavison avatar Sep 26 '24 18:09 burkedavison