gpt4 book ai didi

oauth-2.0 - GoogleCredential.Builder() 无法解析

转载 作者:行者123 更新时间:2023-12-02 15:31:07 28 4
gpt4 key购买 nike

我正在开发一个服务帐户应用程序来获取用于访问下游服务的 token 。但是,我遇到了编译问题。 Eclipse提示错误“The type com.google.api.client.auth.oauth2.Credential$Builder cannot be resolved. It is indirectly referenced from required .class files”。下面的代码片段:

import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson.JacksonFactory;


public class AppMain {

public static void main(String[] args) {
// TODO Auto-generated method stub
final HttpTransport TRANSPORT = new NetHttpTransport();
final JsonFactory JSON_FACTORY = new JacksonFactory();

GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(TRANSPORT)
.setJsonFactory(JSON_FACTORY)
.setServiceAccountId("SOMETHING@developer.gserviceaccount.com")
.setServiceAccountScopes(BigqueryScopes.BIGQUERY)
.setServiceAccountPrivateKeyFromP12File(new File("key.p12"))
.build();
}
}

请帮忙。提前致谢。

最佳答案

我通过覆盖 google-api-client 对此的依赖解决了这个错误 -

    <dependency>
<groupId>com.google.api-client</groupId>
<artifactId>google-api-client</artifactId>
<version>1.22.0</version>
</dependency>

关于oauth-2.0 - GoogleCredential.Builder() 无法解析,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25825270/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com