Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

google analytics - missing OAuth2Native class

I am trying to run a simple example from https://developers.google.com/analytics/solutions/articles/hello-analytics-api to access Google analytic data.

Downloaded the java api-library google-api-java-client-1.17.0-rc.zip from https://code.google.com/p/google-api-java-client/downloads/list,

There example code show compilation error :

    private static final HttpTransport HTTP_TRANSPORT = new NetHttpTransport();

    private static final JsonFactory JSON_FACTORY = new JacksonFactory();

    private static Analytics initializeAnalytics() throws Exception {
        Credential credential = OAuth2Native.authorize(
        HTTP_TRANSPORT, JSON_FACTORY, new LocalServerReceiver(),
        Arrays.asList(AnalyticsScopes.ANALYTICS_READONLY));

        Analytics analytics = Analytics.builder(HTTP_TRANSPORT, JSON_FACTORY)
  .setApplicationName("Hello-Analytics-API-Sample")
  .setHttpRequestInitializer(credential)
  .build();

I added all the libraries in class path but the library doesn't seem to have some classes :

OAuth2Native

AnalyticsScopes

Analytics

But these classes are present on http://code.google.com/p/google-api-java-client/source/browse/shared/shared-sample-cmdline/src/main/java/com/google/api/services/samples/shared/cmdline/oauth2/OAuth2Native.java?repo=samples&r=89662bd8ab341647b3f0aab8ed6a4fb444f478c2

like image 818
bigData Avatar asked Oct 18 '13 06:10

bigData


1 Answers

I recommend downloading the sources from the following link

hg clone https://code.google.com/p/google-api-java-client.samples/

You'll have to use mercurial in order to checkout the project. Once it's downloaded it all runs smoothly and it shows you also an example of the authorization implementation. It works with no dependency issues.

like image 79
liorsolomon Avatar answered Sep 29 '22 19:09

liorsolomon