0

問題の説明

Google analytic ManagementAPI2.4を使用してAnalyticのデータを取得しています。次のエラーが発生する場所

com.google.gdata.util.ServiceForbiddenException: Forbidden
<?xml version="1.0" encoding="UTF-8"?><errors xmlns="http://schemas.google.com/g/2005"><error><domain>GData</domain><code>insufficientPermissions</code><internalReason>User does not have permission to perform this operation</internalReason></error></errors>
atcom.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:605)
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:564)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:560)
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:538)
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:536)
at com.google.gdata.client.Service.getFeed(Service.java:1135)
at com.google.gdata.client.Service.getFeed(Service.java:1077)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:676)
at com.google.gdata.client.Service.getFeed(Service.java:1034)
at com.report.pojo.GoogleAnlytics2.printFirstAccount(GoogleAnlytics2.java:80)
at com.report.pojo.GoogleAnlytics2.main(GoogleAnlytics2.java:91)

私は次のコードを使用しています

public static DataQuery getBasicQuery(String tableId) throws MalformedURLException {
    DataQuery query = new DataQuery(new URL(DATA_URL));
    query.setIds(tableId);
    query.setStartDate("2011-07-12");
    query.setEndDate("2012-07-15");
    query.setDimensions("ga:hour");
    query.setMetrics("ga:visits,ga:bounces");
    query.setStringCustomParameter("key",API_KEY);
    return query;
}

public static void printData(String title, DataFeed dataFeed) {
    System.out.println(title);
    System.out.println(dataFeed.getEntries().size());
    for (DataEntry entry : dataFeed.getEntries()) {
        System.out.println("\tHour: " + entry.stringValueOf("ga:hour"));
        System.out.println("\t\tVisits: " + entry.stringValueOf("ga:visits"));
        System.out.println("\t\tBounces: " + entry.stringValueOf("ga:bounces"));
        System.out.println("\t\tBounce rate: "+ entry.longValueOf("ga:bounces") / (double) entry.longValueOf("ga:visits"));
    }
    System.out.println();
}

BASE_URL="https://www.googleapis.com/analytics/v2.4/management/"
DATA_URL="https://www.googleapis.com/analytics/v2.4/data"

問題に関連するGoogleグループのディスカッションページ(link1link2link3)をいくつか取得しましたが、解決策を取得できませんでした。

この問題を解決するにはどうすればよいですか?

4

1 に答える 1

0

Google API コンソールで Google アナリティクス API を有効にしましたか? Pythonコードを更新していたので、先週これをしなければなりませんでした。

まだこれを行っていない場合は、https://code.google.com/apis/console/でログインし、ステータスを ON に設定します。

Google API コンソール

于 2012-08-27T15:27:49.717 に答える