【发布时间】:2015-06-03 03:59:57
【问题描述】:
是否可以在不使用模拟的情况下将 Google 凭据用于 GMAIL REST API??
在我看到的许多 GMAIL REST API 示例中,必须使用与域和 Google APPS 关联的模拟帐户。我只想使用 GMAIL REST API api server-to-server :
f.e:
GoogleCredential credential = new GoogleCredential.Builder().setTransport(httpTransport)
.setJsonFactory(jsonFactory)
.setServiceAccountId(serviceAccountUserEmail)
**.setServiceAccountUser("myuser@mydomain.com)**
.setServiceAccountScopes(SCOPES)
.setServiceAccountPrivateKeyFromP12File(
new java.io.File(SERVICE_ACCOUNT_PKCS12_FILE_PATH))
.build();
问题是我没有任何域,我只使用一个 GMAIL 帐户......但我没有任何授权方式,例如:MyMainGmailAcccoun@gmail.com
服务帐户 id 4xxxxxxxxxxxxxq@developer.gserviceaccount.com"; 是使用 MyMainGmailAcccoun@gmail.com 创建的“客户帐户”
这毫无意义,我不想冒充另一个域的其他帐户,而且我没有任何方法来授权 MyMainGmailAcccoun@gmail.com。
只有在您有一个帐户来模拟与 Google Apps 关联的其他域并获取 Google Apps 时才有效……您需要一个域。
有什么建议吗?
【问题讨论】:
标签: java rest email google-apps gmail-api