Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
可以将Google API凭据硬编码到我的Java应用程序中吗?_Java_Google Cloud Platform_Credentials - Fatal编程技术网

可以将Google API凭据硬编码到我的Java应用程序中吗?

可以将Google API凭据硬编码到我的Java应用程序中吗?,java,google-cloud-platform,credentials,Java,Google Cloud Platform,Credentials,在中,有命名点1-4如何为我的应用程序提供凭据。所有这些我都不喜欢,因为它们使我的应用程序依赖于环境 是否可以将凭据硬编码到我的应用程序中,例如使用一些API密钥或其他什么?您可以在环境变量中添加API密钥: export GOOGLE_API_KEY="xxxx" 或包含您的凭据的JSON: export GOOGLE_APPLICATION_CREDENTIALS=/home/toto/tmp/project-name-123456789.json

在中,有命名点1-4如何为我的应用程序提供凭据。所有这些我都不喜欢,因为它们使我的应用程序依赖于环境


是否可以将凭据硬编码到我的应用程序中,例如使用一些API密钥或其他什么?

您可以在环境变量中添加API密钥:

export GOOGLE_API_KEY="xxxx"
或包含您的凭据的JSON:

export GOOGLE_APPLICATION_CREDENTIALS=/home/toto/tmp/project-name-123456789.json