Google Drive API through Google App Engine

前端 未结 5 1442
长情又很酷
长情又很酷 2021-01-05 08:13

I\'m trying to use the Google Drive API through the App Identity interface provided with Google App Engine. This basically allows my web application to communicate with Goog

5条回答
  •  攒了一身酷
    2021-01-05 08:39

    What I read here (Google drive via service accounts) was that you use a slightly different style that uses an API KEY that you retrieve from the Developer Console.
    The pertinent parts for me were to generate a "Key for Server Applications", then use this technique, which I hadn't read anywhere else!

          HttpTransport httpTransport = new NetHttpTransport();
      JsonFactory jsonFactory = new JacksonFactory();
      AppIdentityCredential credential =
          new AppIdentityCredential.Builder(DriveScopes.DRIVE).build();
      // API_KEY is from the Google Console as a server API key
      GoogleClientRequestInitializer keyInitializer =
          new CommonGoogleClientRequestInitializer(API_KEY);
      Drive service = new Drive.Builder(httpTransport, jsonFactory, null)
          .setHttpRequestInitializer(credential)
          .setGoogleClientRequestInitializer(keyInitializer)
          .build();
    

提交回复
热议问题