HttpBackOffUnsuccessfulResponseHandler and ExponentialBackOff

38 views
Skip to first unread message

Joe Gilvary

unread,
Sep 30, 2015, 12:03:12 PM9/30/15
to Google Analytics Reporting API
I have a program that works to pull the profiles & user permissions for our accounts, but it usually hits a 403 "Quota Error: User Rate Limit Exceeded" error before it completes all of them. So I am trying to implement the Exponential BackOff, as documented for the version 1.20 APIs.

I replaced:

return new Analytics.Builder(httpTransport, JSON_FACTORY, credential).setApplicationName(APPLICATION_NAME).build();

with:

Analytics.Builder bldr = new Analytics.Builder(httpTransport, JSON_FACTORY, credential).setApplicationName(APPLICATION_NAME);

bldr.setHttpRequestInitializer(new HttpRequestInitializer() {
    public void initialize(HttpRequest request) throws IOException {
        request.setUnsuccessfulResponseHandler(new HttpBackOffUnsuccessfulResponseHandler(new ExponentialBackOff()));
    }
});

return bldr.build();


in my Analytics initializeAnalytics() method.

The new code compiles and runs and returns a 401. Even when I delete the authorization token from the hard drive to force a new authorization request and approval  in the browser, then approve it, I still get a 401 response in the program.

Any ideas? Has anyone seen a working example for this in Java?
Reply all
Reply to author
Forward
0 new messages