0
내 자격 증명 서비스 계정을 사용하여 내장되어자원 서비스 계정 여기
GoogleCredential credential = new GoogleCredential.Builder()
.setJsonFactory(jsonFactory).setTransport(httpTransport)
.setServiceAccountId("[email protected]")
.setServiceAccountPrivateKeyFromP12File(new File("key.p12"))
.setServiceAccountScopes(Collections.singleton(DirectoryScopes.ADMIN_DIRECTORY_USER))
.build();
를 사용 userKey Google 디렉토리의 API를 찾을 수 없습니다 내가 노력하고 모든 사용자가 com.google.api.services이고, 사용자를 얻을 수 있습니다 .admin.directory.model.User
User u = null;
try {
u = service.users().get("[email protected]").execute();
} catch (Exception e) {
e.printStackTrace();
}
return u.toPrettyString();
}
코드 404와 함께 응답이 반환됩니다. 리소스가 없습니다. ?? 사용자를 생성해야합니까? Gmail 사용자에게 액세스하는 방법은 무엇입니까?
서비스 계정 사용자 [email protected]을 추가했습니다. – simpleProgrammer
해결 되었습니까? –
예, 여기에 서비스 계정 사용자로 관리자 이메일을 제공 한 Google Apps 관리자 계정을 만들었으며 googletutorial에 따라 Apps 관리자에서 클라이언트 ID를 추가했습니다. – simpleProgrammer