google app engine - How to initialize Drive Service with GAE -
I need to start a drive service in my GAE application. I'm using 3-legged OAuth 2.0 I am I use a regular Google account (no service account). I'm trying to:
GoogleCredential credentials = usuarioService.getGoogleCredentials (); Drive Service = New Drive. Builder (Transport, JSN_Factory, Credential) .build (); And I get this error:
Reason by: java.lang.NoSuchField error: MAJOR_VERSION com.google.api.services.drive.Drive On. Com.google.api.services.drive.Drive $ Builder.build (Drive.java:8243) & lt; clinit & gt; (Drive.java48) The OAuth 2.0 Flow Authority is working on the work, I get the above mentioned error.
I do not think my Google credentials are incorrect because I use the same method to get authorization to use Google Picker.
How do I get GoogleCredential from the user:
GoogleCredential credentials = new GoogleCredential.Builder () .setClientSecrets (clientId, clientSecret) .setJsonFactory (JSON_FACTORY). SetTransport (HTTP_TRANSPORT) .build () .setRefreshToken (user.getOAuth2RefreshToken ()) .setAccessToken (user.getOAuth2AccessToken ()); // Previous access token Can you help me?
Diego
UPDATE I have updated the disk library (v2) and google-api-client 1.18 and it still does not work. Now I get this error:
Reason by: java.lang.NoClassDefFoundError: Class can not be started com.google.api.services.drive. Drive 2 When I rebuild GoogleCredential Object, I am doing something wrong. Has tried to call on the drive. Producer () when I request the original credentials from the authorization flow: the last GoogleTokenResponse response = flow. NutokNuQ (authCode) .setRedirectUri (callback) .execute (); Credential credential = Flow.Cut and store credentials (response, blank); Calling for drive service drive service = new drive. Builder (httpTransport, jsonfactory, credential) .build (); I get the same error:
By reason: java.lang.NoSuchField error: MAJOR_VERSION I do the same with the calendar and I get the same error I am using the next libraries: google-api-client 1.18
Google-api-client-servlet 1.18
google-api-service-drive-v2-1.18
google-http-client 1.18
google-http -client-jackson 1.18
Google-oauth-client 1.18
Solution: < I cleaned my project of some libraries And I'm using 1.15 version of Google libraries and it's working (the same code).
Comments
Post a Comment