Google cloud platform Google凭据:来自云ML引擎实例的授权

Google cloud platform Google凭据:来自云ML引擎实例的授权,google-cloud-platform,google-cloud-storage,google-cloud-ml,google-cloud-ml-engine,Google Cloud Platform,Google Cloud Storage,Google Cloud Ml,Google Cloud Ml Engine,我有一个针对Cloud ML engine的培训师应用程序,其中我必须使用kms对我在Google云存储中的文件进行解密。 我可以使用tensorflow.python.lib.io.file_io下载GCS中的文件,而无需提供任何凭据,因为用于启动培训作业的服务帐户可以访问正在下载加密文件的GCS存储桶。 但是,我无法获取默认的应用程序凭据 credentials = GoogleCredentials.get_application_default() 上述调用返回一个空凭证对象,其中大多

我有一个针对Cloud ML engine的培训师应用程序,其中我必须使用kms对我在Google云存储中的文件进行解密。 我可以使用
tensorflow.python.lib.io.file_io
下载GCS中的文件,而无需提供任何凭据,因为用于启动培训作业的服务帐户可以访问正在下载加密文件的GCS存储桶。 但是,我无法获取默认的应用程序凭据

credentials = GoogleCredentials.get_application_default()
上述调用返回一个空凭证对象,其中大多数字段为
null

{"scopes": [], "id_token": null, "kwargs": {}, "token_response": null, "client_id": null, "scope": "", "token_expiry": null, "_class": "AppAssertionCredentials", "refresh_token": null, "_module": "oauth2client.contrib.gce", "_service_account_email": null, "access_token": null, "invalid": false, "token_info_uri": null, "assertion_type": null, "token_uri": "https://www.googleapis.com/oauth2/v4/token", "client_secret": null, "revoke_uri": "https://accounts.google.com/o/oauth2/revoke", "user_agent": null}
我原以为云ML引擎为培训作业提供的实例应该在该实例中自动填充我的服务密钥,但情况似乎并非如此

关于如何获取访问凭据的任何提示。(除了在培训师套餐中包含凭据外:)


任何帮助都将不胜感激。

我认为返回的
凭证
对象看起来只是空的,但是如果您调用

print credentials.get_access_token() 打印凭据。获取\u访问\u令牌() 它将实际生成一个有效的访问令牌。也可以使用它来授权HTTP请求或API库,如中所述。有关可用方法的列表,请参见