我尝试使用 JAVA API 设置 BigQuery 项目来访问它。但是,当我运行此处的 google BigQueryInstalledAuthDemo 类时,出现此错误:
java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
at com.google.api.client.json.jackson.JacksonFactory.createJsonParser(JacksonFactory.java:70)
at com.google.api.client.json.JsonFactory.fromInputStream(JsonFactory.java:223)
at com.google.api.client.googleapis.auth.oauth2.GoogleClientSecrets.load(GoogleClientSecrets.java:167)
at BigQueryLocal.loadClientSecrets(BigQueryLocal.java:99)
at BigQueryLocal.<clinit>(BigQueryLocal.java:31)
Exception in thread "main" java.lang.NullPointerException
at com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeRequestUrl. <init>(GoogleAuthorizationCodeRequestUrl.java:111)
at BigQueryLocal.main(BigQueryLocal.java:47)
我不明白,我的 JSON 文件与类位于同一文件夹中(我尝试了相对路径和绝对路径)我的 JSON 文件是这样的:
{
"installed": {
"client_id": "XXXXXXXXXXXXXXXXXXXX.apps.googleusercontent.com",
"client_secret": "XXXXXXXXXXXXXXXXX",
"redirect_uris": ["urn:ietf:oauth:2.0:oob"],
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token"
}
}
我使用谷歌 API 库 1.12-beta 和 java 1.6。所以,我不明白为什么我有这个错误:(,所以如果有人有想法......
谢谢 :)