GMail REST API:使用Google凭据而不进行模拟 [英] GMail REST API: Using Google Credentials Without Impersonate
问题描述
可以在不使用模拟的情况下使用Google Credentials进行GMAIL REST API吗?
Is it possible to use Google Credentials for GMAIL REST API without using impersonation??
在GMAIL REST API的许多示例中,我看到必须使用模拟帐户与域和Google APPS关联。我只想使用GMAIL REST API api服务器到服务器:
In many examples of GMAIL REST API i see is mandatory to use an impersonation account associated to a domain and Google APPS. I just want to use GMAIL REST API api server-to-server :
fe:
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
The matter is that i don't have any domain and i use just a GMAIL account...but i don't get any way to authorize, for example : MyMainGmailAcccoun@gmail.com
服务帐号id 4xxxxxxxxxxxxqq.developer.gserviceaccount.com;是使用MyMainGmailAcccoun@gmail.com创建的客户帐户
The servive acccount id 4xxxxxxxxxxxxxq@developer.gserviceaccount.com"; is a "client account" created with the MyMainGmailAcccoun@gmail.com
这没有意义,我不想假冒没有另一个域名的其他帐号,我没有办法创建MyMainGmailAcccoun@gmail.com。
This has no sense , i don't want to impersonate with no other account of another domain, and i don't get any way to authozize MyMainGmailAcccoun@gmail.com .
只有您有帐户才能模拟其他域名与Google Apps关联的域名,并获得Google Apps ...您需要一个域。
Just only works, if you have an account to impersonate of other domain associated with Google Apps, and to get Google Apps...you need a domain.
任何建议??
推荐答案
您可能只想使用 OAuth 2.0 for Web Server应用程序。假设您需要超过一个小时的授权,您可以使用刷新令牌。
You may just want to simply use OAuth 2.0 for Web Server Applications. Assuming you want the authorization for more than an hour, you can use refresh tokens.
这篇关于GMail REST API:使用Google凭据而不进行模拟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!