语境
我在 Google AppEngine 灵活环境中有一些服务通过 API 进行通信,同时我使用 IAP 来管理用户访问。我必须使用 Bearer JWT 令牌以编程方式对每个服务进行身份验证。
问题
在我的 Java 应用程序中,我使用 google 提供的代码来验证 IAP 服务,您可以在此处找到:https ://cloud.google.com/iap/docs/authentication-howto#iap_make_request-java
问题出在这段代码中:
GoogleCredentials credentials =
GoogleCredentials.getApplicationDefault().createScoped(Collections.singleton(IAM_SCOPE));
// service account credentials are required to sign the jwt token
if (credentials == null || !(credentials instanceof ServiceAccountCredentials)) {
throw new Exception("Google credentials : service accounts credentials expected");
}
return (ServiceAccountCredentials) credentials;
该createScoped
方法正在返回一段ComputeEngineCredentials
时间,代码需要一个ServiceAccountCredentials
响应对象。
欢迎所有建议。提前感谢有史以来最伟大的社区。