항아리를 가져 오는 앱 엔진 앱이 있습니다. 그 항아리에서 나는 GoogleClientSecrets.load() 을 사용하여 BigQuery로 인증하기 위해 client_secrets.json 파일을로드합니다. 분명히 App Engine은 로컬 호스트에 앱을 배포 할 때 내 디스크의 일부 위치에서 파일을 읽는 것을 좋아하지 않습니다. WEBINF 폴더에 자격 증명을 입력하면 작동하지만 테스트하지 않았지만 누구든지 파일에 액세스하기 쉽습니다. 자격증 명을 넣을 수있는 가장 좋은 곳은 어디이고 App Engine 앱에서 자격증 명에 액세스하는 방법은 무엇입니까?App Engine 자격증 명 문제
도움 주셔서 감사합니다.
제안 사항은 파일을 읽을 때 문제를 해결하는 데 도움이되었습니다. 파일에 쓰는 것은 어떨까요? 자격 증명 파일을 저장하는 FileCredentialStore를 사용하고 있습니다.
이 줄이 문제의 원인이라고 생각합니다. FileCredentialStore variantStoreCredentialManager = new FileCredentialStore (expectedClientFile, jsonFactory); 및 오류가 java.security.AccessControlException입니다 : 액세스가 거부 ("java.io.FilePermission의"파일 경로 "쓰기")
public Bigquery createAuthorizedClient() throws IOException {
Credential authorization = new GoogleCredential();
if (clientID == null) {
authorization = createWebAuthenticatedClientCredential();
} else {
String expectedFileLocation = CREDENTIAL_FILE_PATH;
File expectedClientFile = new File(expectedFileLocation);
if (! expectedClientFile.exists()) {
// this is a known issue, the credential store will blow up if the file doesn't exist. So create it with an
// empty json ({ })
createClientFile(expectedClientFile);
}
FileCredentialStore variantStoreCredentialManager = new FileCredentialStore(expectedClientFile,jsonFactory);
GoogleCredential.Builder credentialBuilder = new GoogleCredential.Builder();
credentialBuilder.setJsonFactory(jsonFactory);
credentialBuilder.setClientSecrets(clientSecrets);
credentialBuilder.setTransport(transport);
authorization = credentialBuilder.build();
boolean loadedSuccessfully = variantStoreCredentialManager.load(clientID,authorization);
if (! loadedSuccessfully ) {
authorization = createWebAuthenticatedClientCredential();
variantStoreCredentialManager.store(clientID, authorization);
}
}
return new Bigquery(transport, jsonFactory, authorization);
}
'/ WEB-INF'는 이러한 데이터를 넣기에 적합한 장소입니다. 파일이 아닌 리소스로 액세스하십시오. http://stackoverflow.com/questions/4340653/file-path-to-resource-in-our-war-web-inf-folder –
답장을 보내 주셔서 감사합니다. – Tad