I'm using APIKEY to set up the transport and initialize the connection to retrieve activities from Google Plus.
HttpRequestInitializer initializer = (HttpRequestInitializer) new CommonGoogleClientRequestInitializer("GooglePlusAPIKey");
plusSvc = new Plus(new NetHttpTransport(), new GsonFactory(), initializer);
It gives me this error:
CommonGoogleClientRequestInitializercannot be cast toHttpRequestInitializer.
How do I fix this?
The error message is correct. HttpRequestInitializer and CommonGoogleClientRequestInitializer are not directly related, so the cast is illegal. They are just similar classes in different packages -- you cannot mix-n-match like this.
See docs here: http://javadoc.google-api-java-client.googlecode.com/hg/1.12.0-beta/com/google/api/client/googleapis/services/CommonGoogleClientRequestInitializer.html
The examples here may be easier to follow: https://code.google.com/p/google-api-java-client/wiki/OAuth2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With