如何在Rails3中使用oauth连接到Gmail的IMAP服务器? [英] How do I connect to Gmail's IMAP server using oauth in Rails3?

查看:211
本文介绍了如何在Rails3中使用oauth连接到Gmail的IMAP服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找到了 gmail_xoauth 宝石,它可以完成我所需要的大部分工作,但我也需要从Rails3内部生成oauth令牌(consumer_key和consumer_secret)。



我正在尝试将Gmail的oauth集成集成到我的网站中,因此无法使用上述gem指的是。我希望我的网站将用户带到身份验证页面并提取consumer_key / secret标记。



我是OAuth的新手,所以也许有一些显而易见的东西是我失踪。

更新:我解决了上述问题,并且写了一篇博客文章(因为它太大而不适合这里)。
http://blog.asif .in / blog / 2012/03/03 / google-oauth-and-rails /

解决方案

希望查看 OmniAuth 。这是一个gem,它封装/提取许多必须为OAuth完成的底层协议工作,以及其他认证/授权协议,如OpenID和LDAP。我对Google的发送/接收电子邮件的API并不熟悉,但认证是第一步。

OmniAuth wiki有非常好的 tutorial 关于将它与OpenID和Google Apps一起使用,尽管这可能不是您想要的,当涉及到IMAP时,请重新寻找。您可能需要为OmniAuth编写自己的提供者(一个很好的教程描述这是可用的)。 Google还提供参考网站,以便通过IMAP和OAuth进行身份验证/授权。与您最相关的部分很可能是详细说明协议< a>。



希望有帮助!


I found the gmail_xoauth gem, which does most of what I need, but I also need to generate the oauth tokens (consumer_key and consumer_secret) from inside Rails3.

I am trying to integrate Gmail's oauth integration into my site and hence cannot use the python script that the above gem refers to. I would like my site to take the user to the authentication page and extract the consumer_key/secret tokens.

I am new to OAuth, so maybe there's something obvious that I am missing.

UPDATE: I solved the above, and have written a blog post with the details (since its too big to fit here). http://blog.asif.in/blog/2012/03/03/google-oauth-and-rails/

解决方案

You may want to check out OmniAuth. It's a gem that encapsulates/abstracts a lot of the underlying protocol work that must be done for OAuth, as well as other authentication/authorization protocols like OpenID and LDAP. I'm not well versed on Google's API for sending/receiving email, but authenticating is the first step.

The OmniAuth wiki has a very good tutorial on using it with OpenID and Google Apps, although this may not be quite what you're looking for when it comes to IMAP. You may need to write your own provider for OmniAuth (a good tutorial describing this is available). Google also provides a reference site for authenticating/authorizing via IMAP and OAuth. The most relevant part of that to you would most likely be the page detailing the protocol.

Hope that helps!

这篇关于如何在Rails3中使用oauth连接到Gmail的IMAP服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆