相关疑难解决方法(0)

如何使用python以编程方式获取GCP Bearer令牌

gcloud auth print-access-token给我一个Bearer令牌,以后可以使用;但是,这是一个shell命令。如何通过Google Cloud Python API以编程方式获取一个?

我看到了使用oauth2client先前示例,但现在已弃用。如何使用google.authoauthlib做到这一点oauth2client

python google-cloud-platform google-iam

10
推荐指数
4
解决办法
3486
查看次数

为什么Google Cloud API尝试以最终用户身份进行连接?

我正在尝试使用Google Cloud Translate API。我从服务帐户生成了JSON文件,并将设置GOOGLE_APPLICATION_CREDENTIALS为JSON文件的保存位置。然后,我在这样的程序中使用了它:

import com.google.cloud.translate.*;
...
Translate translate = TranslateOptions.getDefaultInstance().getService();
Translation translation = translate.translate(message);
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误

com.google.cloud.translate.TranslateException: Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the translate.googleapis.com. We recommend that most server applications use service accounts instead. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/
        at com.google.cloud.translate.spi.v2.HttpTranslateRpc.translate(HttpTranslateRpc.java:61)
        at com.google.cloud.translate.spi.v2.HttpTranslateRpc.translate(HttpTranslateRpc.java:144)
        at com.google.cloud.translate.TranslateImpl$4.call(TranslateImpl.java:113)
        at com.google.cloud.translate.TranslateImpl$4.call(TranslateImpl.java:110)
        at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:89)
        at …
Run Code Online (Sandbox Code Playgroud)

java authentication json google-translate google-cloud-platform

7
推荐指数
1
解决办法
378
查看次数