使用XOAUTH2访问Google域用户电子邮件数据

我正在尝试使用xoauth2从我们的谷歌应用程序访问我们的学生gmail数据。

我一直在这个区域,googles文档的组织非常糟糕,而且还有很多旧的文档不再适用于你所指向的,所以它很有趣。

我基本上使用我创建的已启用域委派的服务帐户在python中使用googles oauth2client来使用以下代码。

from oauth2client.client import SignedJwtAssertionCredentials client_email = 'serviceaccount@developer.gserviceaccount.com' with open("testserviceaccount.p12") as f: private_key = f.read() credentials = SignedJwtAssertionCredentials(client_email, private_key, 'https://www.googleapis.com/auth/gmail.readonly', sub='student email address') from httplib2 import Http http_auth = credentials.authorize(Http()) from apiclient.discovery import build service = build('gmail', 'v1', http=http_auth ) messages = service.users().messages().list(userId='student email address').execute() print messages 

我需要这个应用程序的应用程序是在轨道上的ruby,所以我正在寻找任何提示或帮助在Ruby on Rails中使用什么来实现相同的效果。

任何帮助或提示非常感谢。