我正试图用我自己的账号将一个java应用认证到google photos api中,根据文档,它不支持service_account。问题是google-console为OAuth2认证生成的文件不包含类型字段,只有为服务账户创建凭证生成的文件才能工作。
我尝试通过 gcloud auth application-default login
而不读取生成的文件,该文件中确实包含一个typeclient_idclient_secretrefresh_token。
E.G.。
PhotosLibrarySettings settings =
PhotosLibrarySettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(
GoogleCredentials.fromStream(
new FileInputStream("credentials.json")
)))
.build();
任何想法,可能会有帮助?