実装したい機能
GoogleKeepで作成したメモの一覧と、その内容を取得する機能を実装したいと考えています。
現状
GoogleKeepApiを使用しメモの一覧を取得しようとしていますが、空のリストが帰ってくる状態です。
開発環境等
- IDE:Eclipse Neon.3 Release (4.6.3)
- 言語:Java
- jdk:jdk1.8.0_191
GoogleCloud側の設定
- GoogleKeepApi:有効化済み
- OAuth同意画面:作成済み
- サービスアカウント:作成済み
現状の実装
private static final String APPLICATION_NAME = "**********";
private static final JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();
private static final List<String> SCOPES = Collections.singletonList(KeepScopes.KEEP);
private GoogleCredentials getCredentials(final NetHttpTransport HTTP_TRANSPORT, String temple_code) throws IOException {
String gredentials_file_path = "********************" + "/credentials.json";
// Load client secrets.
AmazonUtil amazon = new AmazonUtil(configuration);
AmazonS3 amazonS3Client = amazon.createAmazonS3();
S3Object s3Obj = amazon.downLoadS3Object(amazonS3Client, gredentials_file_path);
InputStream in = s3Obj.getObjectContent();
GoogleCredentials googleCredentials = GoogleCredentials.fromStream(in).createScoped(SCOPES);
return googleCredentials;
}
public void loadDocuments(String temple_code) throws GeneralSecurityException, IOException, ErrorCheckException {
final NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
GoogleCredentials credential = getCredentials(HTTP_TRANSPORT, temple_code);
Keep service = new Keep.Builder(HTTP_TRANSPORT, JSON_FACTORY, new HttpCredentialsAdapter(credential))
.setApplicationName(APPLICATION_NAME)
.build();
Notes notes = service.notes();
System.out.println(notes);
Keep.Notes.List notes_list = notes.list();
System.out.println(notes_list);
ListNotesResponse response = notes_list.execute();
System.out.println(response);
}
出力
com.google.api.services.keep.v1.Keep$Notes@6384c9de
GenericData{classInfo=[$.xgafv, access_token, alt, callback, fields,
filter, key, oauth_token, pageSize, pageToken, prettyPrint, quotaUser,
uploadType, upload_protocol], {}}
{}