我们有一个Google Analytics帐户,可以跟踪最常搜索的字词。我想在java中获取该报告。为此,我尝试按照以下链接:Hello Analytics API: Java quickstart for service accounts
SERVICE_ACCOUNT_EMAIL:208051463715-compute208051463715-compute@developer.gserviceaccount.com)to@developer.gserviceaccount.com
KEY_FILE_LOCATION:我们将文件保存在我们保存analytics.java file.below link的同一目录中,并按照下面提到的步骤进行操作。
但是我们遇到了以下错误:
运行java类时,我们会遇到异常,如下所示:
com.google.api.client.googleapis.auth.oauth2.GoogleCredential@39fb3ab6 com.google.api.client.auth.oauth2.TokenResponseException:400错误请求 { "错误":" invalid_grant" } 在com.google.api.client.auth.oauth2.TokenResponseException.from(TokenResponseException.java:105) 在com.google.api.client.auth.oauth2.TokenRequest.executeUnparsed(TokenRequest.java:287) 在com.google.api.client.auth.oauth2.TokenRequest.execute(TokenRequest.java:307) 在com.google.api.client.googleapis.auth.oauth2.GoogleCredential.executeRefreshToken(GoogleCredential.java:384) 在com.google.api.client.auth.oauth2.Credential.refreshToken(Credential.java:489) 在com.google.api.client.auth.oauth2.Credential.intercept(Credential.java:217) 在com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859) 在com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:419) 在com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:352) 在com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:469) 在com.hm.backstage.components.util.HelloAnalytics.getFirstProfileId(HelloAnalytics.java:68) 在com.hm.backstage.components.util.HelloAnalytics.main(HelloAnalytics.java:33 **)