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:
CommonGoogleClientRequestInitializer
cannot 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.
The examples here may be easier to follow: https://code.google.com/p/google-api-java-client/wiki/OAuth2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.