Google App Engine 위에 GMail API가있는 Google API 클라이언트를 사용하여 여러 사용자의 Gmail 메시지를 수정하려고합니다.하나의 웹 응용 프로그램에서 여러 Gmail 사용자의 전자 메일 액세스
흐름 개요 : 사용자가 대기열에 메시지를 추가하는 요청을 웹 응용 프로그램에 보냅니다. 이 요청에서 Gmail 계정은 주어진 메시지의 존재 여부를 확인합니다. 이 메시지는 나중에 사용자가 다른 요청을하지 않고 cron 작업을 통해 처리됩니다. 나에게 주어진 처리 할 수 있도록 기본적으로 나에게 사용자의 사서함에 오프라인 액세스를 제공해야합니다
private static GoogleClientSecrets getClientCredential() throws IOException {
return GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(Utils.class.getResourceAsStream("/client_secret.json")));
}
public static GoogleAuthorizationCodeFlow newFlow(final String userId) throws IOException {
return new GoogleAuthorizationCodeFlow.Builder(HTTP_TRANSPORT, JSON_FACTORY,
getClientCredential(), Collections.singleton(GmailScopes.GMAIL_MODIFY))
.setDataStoreFactory(DATA_STORE_FACTORY)
.setAccessType("offline")
.setApprovalPrompt("force")
.addRefreshListener(
new DataStoreCredentialRefreshListener(userId, DATA_STORE_FACTORY))
.build();
}
public static Gmail loadGmailClient(final String userId) throws IOException {
final Credential credential = newFlow(userId).loadCredential(userId);
return new Gmail.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName(APP_NAME)
.build();
}
:
나는 문서의 API를 사용하여 다음 두 가지 방법을 가지고하는 방법에 대한 예제를 따라 cron에서 나중에 메시지.userId
이 "me"
이면 모든 것이 정상적으로 작동하는 것 같습니다. 그러나 실제로 사용자가 웹 애플리케이션에 요청하지 않고 수정해야하는 cron 작업 단계에서는 "me"
을 사용할 수 없지만 사용자 ID를 사용해야합니다. 따라서 요청 단계에서 UserServiceFactory.getUserService().getCurrentUser().getUserId()
을 userId
으로 시작하여이 ID를 cron 작업 데이터와 함께 저장합니다. 뭔가, 자격 증명에 문제가 있습니다 그러나 대표단 것 같다 것처럼
com.google.api.client.googleapis.json.GoogleJsonResponseException: 403
{
"code" : 403,
"errors" : [ {
"domain" : "global",
"message" : "Delegation denied for [email protected]",
"reason" : "forbidden"
} ],
"message" : "Delegation denied for [email protected]"
}
처럼 점점 오류가 계속은 "대표단은"분명히 보인다 Google Apps와 완전히 다른 무엇인가? 누구든지 나를 올바른 방향으로 인도 할 수 있습니까?