Google이 현지화된 사이트로 리디렉션되기 때문에 GData Java 클라이언트가 작동하지 않습니다.
-
21-08-2019 - |
문제
나는 문서를 따르고 있습니다. Google Analytics 데이터 API - 자바 그리고 나는 RedirectRequiredException
예외, Google은 저를 로컬 버전의 사이트 (www.google.si)로 리디렉션하기 때문입니다.
코드:
AnalyticsService as = new AnalyticsService("me-myapp-1.0");
as.setUserCredentials(username, password);
AccountFeed accountFeed = as.getFeed(
new URL("https://www.google.com/analytics/accounts/default"),
AccountFeed.class);
마지막 메소드 호출은 다음을 발생시킵니다:
Exception in thread "main" com.google.gdata.util.RedirectRequiredException: Found
<HTML><HEAD><meta http-equiv="content-type" content="text/
html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.si/">here</A>.
</BODY></HTML>
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse (GoogleGDataRequest.java:541)
at com.google.gdata.client.http.HttpGDataRequest.checkResponse (HttpGDataRequest.java:535)
at com.google.gdata.client.http.HttpGDataRequest.execute (HttpGDataRequest.java:514)
at com.google.gdata.client.http.GoogleGDataRequest.execute (GoogleGDataRequest.java:515)
at com.google.gdata.client.Service.getFeed(Service.java:1016)
at com.google.gdata.client.Service.getFeed(Service.java:879)
at com.google.gdata.client.GoogleService.getFeed(GoogleService.java:638)
at com.google.gdata.client.Service.getFeed(Service.java:898)
at org.kubje.jaka.gapump.App.main(App.java:42)
어떤 아이디어가 있나요?
또한 Analytics API의 Google 그룹에도 이 질문을 게시했습니다. 여기.
해결책
URL이 잘못되었습니다.예제에서 복사했는데 올바르지 않습니다.
제휴하지 않습니다 StackOverflow