使用user.profile和user.email范围和/的oauth2 / V2 /用户信息进似乎并没有返回任何自定义字段(在我的情况下,部)或电话号码。 这些字段中域共享联系人目录显示出来。
是否有可能是一个应用程序特定领域的馈源URL类似/的oauth2 / {} DOMAIN / V2 /用户信息?
这个API /服务不支持任何自定义字段了吗?
有没有办法蒙混过关进入工作呢?
读取权限的连接到您的帐户不应该这么难自己的应用程序域共享联系人资料。
在App Engine应用程序:(密码user)和访问/ M8 /饲料,因为我的域使用通用访问卡W / SAML认证,所以我不能只是存储管理员凭据我宁愿一个非管理员的解决方案。 如果有访问域共享联系人(自定义字段)用事先授权的使用者密钥和机密的流程我很想在获得该工作的说明。
编辑杰伊李钉它“ https://www.google.com/m8/feeds/gal/ {}域/全”
这里的概念脚本的使用谷歌Apps脚本证明(当我完成它,我会在最后加上的OAuth2版本)
function getGal(email, passwd, domain) {
var res = UrlFetchApp.fetch("https://www.google.com/accounts/ClientLogin", {
contentType: "application/x-www-form-urlencoded",
method: "post",
payload: { "Email": email, "Passwd": passwd, "accountType": "HOSTED", "service":"cp" }
});
var auth = res.getContentText().match(/Auth=(.*)/i)[1];
Logger.log("Auth: " + auth);
res = UrlFetchApp.fetch("https://www.google.com/m8/feeds/gal/" + domain + "/full", {
method: "get",
headers: { "Authorization": "GoogleLogin auth=" + auth, "GData-Version": "1.0" }
});
Logger.log(res.getHeaders());
Logger.log(res.getContentText());
}
编辑2 OAuth的版本,返回JSON只为用户访问脚本的信息。
function googleOAuthM8() {
var oAuthConfig = UrlFetchApp.addOAuthService("m8");
oAuthConfig.setRequestTokenUrl('https://www.google.com/accounts/OAuthGetRequestToken?scope=https://www.google.com/m8/feeds/');
oAuthConfig.setAuthorizationUrl('https://www.google.com/accounts/OAuthAuthorizeToken');
oAuthConfig.setAccessTokenUrl('https://www.google.com/accounts/OAuthGetAccessToken');
oAuthConfig.setConsumerKey('anonymous');
oAuthConfig.setConsumerSecret('anonymous');
return {oAuthServiceName:"m8", oAuthUseToken:'always'};
}
function getGal(domain) {
res = UrlFetchApp.fetch("https://www.google.com/m8/feeds/gal/" + domain + "/full?alt=json&q=" + Session.getActiveUser().getEmail(), googleOAuthM8());
Logger.log(res.getHeaders());
Logger.log(res.getContentText());
}
任何非管理员用户可以通过编程访问GAL,请参阅:
https://github.com/google/gfw-deployments/blob/master/apps/shell/gal/gal_feed.sh
我不相信这个API调用文档或正式支持,但它甚至与OAuth认证工作,而不是在这个例子的ClientLogin的(上的OAuth 2.0操场测试与非管理员用户和标准https://www.google.com/m8/feeds/
联系人范围)。
需要注意的是全局地址列表的用户个人资料,群组和共享联系人的汇编。 你需要分析它出去找你希望得到部门的信息为用户(或多个)。
我将利用谷歌应用套件配置文件API来做到这一点。 它会给你一堆的元信息,包括个人资料数据,甚至个人资料照片: https://developers.google.com/google-apps/profiles/
即使您正在使用PIV / CAC / SAML,您将能够使用双足式-的OAuth要权威性。 https://developers.google.com/accounts/docs/OAuth#GoogleAppsOAuth
两条腿的,OAuth是阻力最小的路径,但你也应该看看的OAuth2,尤其是智威汤逊签署的服务帐户部分 - 但是,它可以是一个有点棘手得到与老的GData的XML API工作。
至于可用字段去,你必须与此页面上的那些工作。 在有些情况下,你在任意的数据添加扩展属性,但他们没有在联系人浏览器与谷歌邮件本身显示: https://developers.google.com/gdata/docs/2.0/elements#gdProfileKind
在阿里纳斯,如果你在一个LDAP环境是(因为你提到CAC,我想你大概是),你应该看看谷歌Apps目录同步,可与当地的AD / LDAP同步该配置文件数据。
来源:我部署谷歌Apps的大型企业(3000+),公共和私人。
我已经使用TwoLeggedOAuthHmacToken以下方法:消费者密钥和密码可以在谷歌找到Apps管理员控制台
CONSUMER_KEY = 'domain.com'
CONSUMER_SECRET = 'secret_key'
class ContactClient():
def __init__(self, username):
# Contacts Data API Example ====================================================
self.requestor_id = username + '@' + CONSUMER_KEY
self.two_legged_oauth_token = gdata.gauth.TwoLeggedOAuthHmacToken(
CONSUMER_KEY, CONSUMER_SECRET, self.requestor_id)
self.contacts_client = gdata.contacts.client.ContactsClient(source=SOURCE_APP_NAME)
self.contacts_client.auth_token = self.two_legged_oauth_token
def newuser(self, username):
self.contacts_client.auth_token.requestor_id = username + '@' + CONSUMER_KEY
def getContacts(self, username=None):
if username:
self.newuser(username)
return self.contacts_client.GetContacts()
class MainPage(webapp2.RequestHandler):
def get(self):
contacts = ContactClient(username='username')
feed = contacts.getContacts()
output = ""
if feed:
for entry in feed.entry:
if entry.title and entry.title.text:
output += entry.title.text + "<br/>"
for email in entry.email:
if email.primary and email.primary == 'true':
output += ' %s<br/>' % (email.address)
self.response.headers['Content-Type'] = 'text/html'
self.response.write('''<h1>Contact Access via GData Client</h1>''' + output)
文章来源: How to get Google profile info including custom fields from an Apps Domain user?