codecamp

Spring Cloud GCP 凭证

CredentialsProvider是一个功能接口,可返回凭据以认证和授权对Google Cloud Client库的调用。

public interface CredentialsProvider {
  Credentials getCredentials() throws IOException;
}

Spring Cloud GCP启动器会自动配置CredentialsProvider它使用spring.cloud.gcp.credentials.location属性找到Google服务帐户的OAuth2私钥。请记住,此属性是Spring资源,因此可以从许多 不同的位置( 例如文件系统,类路径,URL等)获取凭证文件。下一个示例在文件系统中指定凭证位置属性。

spring.cloud.gcp.credentials.location=file:/usr/local/key.json

或者,您可以通过直接指定spring.cloud.gcp.credentials.encoded-key属性来设置凭据。该值应为JSON格式的base64编码的帐户私钥。

如果未通过属性指定凭据,则启动程序将尝试从许多地方发现凭据

  1. GOOGLE_APPLICATION_CREDENTIALS环境变量指向的凭据文件
  2. Google Cloud SDK gcloud auth application-default login命令提供的凭据
  3. Google App Engine内置凭据
  4. Google Cloud Shell内置凭据
  5. Google Compute Engine内置凭据

如果您的应用程序在Google App Engine或Google Compute Engine上运行,则在大多数情况下,您应该省略spring.cloud.gcp.credentials.location属性,而应让Spring Cloud GCP Starter获得那些环境的正确凭据。在App Engine Standard上,使用 App Identity服务帐户凭据 ;在App Engine Flexible上,使用Flexible服务帐户凭据;在Google Compute Engine上,使用Compute Engine默认服务帐户

Spring Cloud GCP 项目ID
Spring Cloud GCP 范围
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

三、Spring Cloud Netflix

SpringCloud Hystrix超时和Ribbon客户

SpringCloud 重试失败的请求

五、Spring Cloud Stream

六、SpringCloud Binder实现

SpringCloud 重试RabbitMQ Binder

SpringCloud Dead-Letter队列处理

八、Spring Cloud Sleuth

SpringCloud 当前Span

十二、Spring Cloud for Cloud Foundry

十三、Spring Cloud Contract

Spring Cloud Contract验证程序设置

SrpingCloud Gradle项目

十五、Spring Cloud网关

Spring Cloud 配置路由谓词工厂和网关过滤工厂

Spring Cloud TLS / SSL

Spring Cloud网关配置

SpringCloud 故障排除

十八、Spring Cloud GCP

Spring Cloud GCP Spring资源

Spring Cloud Spring JDBC

Spring Cloud Redis的Cloud Memorystore

Spring Cloud 云身份识别代理(IAP)身份验证

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }