是否可以在不使用模拟的情况下使用 GMAIL REST API 的 Google 凭据?
在许多 GMAIL REST API 示例中,我看到必须使用与域和 Google APPS 关联的模拟帐户。我只想使用 GMAIL REST API api 服务器到服务器:
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 时才有效...您需要一个域。
有什么建议吗??
最佳答案
您可能只想简单地使用 OAuth 2.0 for Web Server Applications .假设你想要一个多小时的授权,你可以使用refresh tokens .
关于java - Gmail REST API : Using Google Credentials Without Impersonate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29341096/