如何在 Rails3 中使用 oauth 连接到 Gmail 的 IMAP 服务器?
我找到了 gmail_xoauth gem,它可以满足我的大部分需要,但我还需要生成 oauth来自 Rails3 内部的令牌(consumer_key 和consumer_secret)。
我正在尝试将 Gmail 的 oauth 集成集成到我的网站中,因此无法使用上述 gem 引用的 python 脚本。我希望我的网站将用户带到身份验证页面并提取消费者密钥/秘密令牌。
我是 OAuth 新手,所以也许我遗漏了一些明显的东西。
更新:我解决了上述问题,并写了一篇包含详细信息的博客文章(因为它太大,不适合放在这里)。 http://blog.asif.in/blog /2012/03/03/google-oauth-and-rails/
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/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可能需要查看 OmniAuth。它是一个 gem,封装/抽象了 OAuth 以及其他身份验证/授权协议(如 OpenID 和 LDAP)必须完成的许多底层协议工作。我不太熟悉 Google 发送/接收电子邮件的 API,但身份验证是第一步。
OmniAuth wiki 有一个非常好的教程,介绍如何将其与 OpenID 结合使用和 Google Apps,尽管这可能不是您在 IMAP 方面所寻找的。您可能需要为 OmniAuth 编写自己的提供程序(一个很好的教程< /a> 对此进行了描述)。 Google 还提供了一个参考网站,用于通过 IMAP 和 OAuth 进行身份验证/授权。其中与您最相关的部分很可能是详细说明协议的页面。
希望有帮助!
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!
我不会为您编写完整的代码,但是您了解 PHP 吗?您可以查看此示例的工作方式:
http://googlecodesamples.com/docs/php /Docs.php
...然后用 Ruby 做类似的事情。
这是来自以下网站的 Google 代码示例:
http://googlecodesamples.com/
I'm not going to write the full code for you, but do you know PHP? You could have a look at the way this example works:
http://googlecodesamples.com/docs/php/Docs.php
...then make something similar in Ruby.
This is a Google Code Sample from the following site:
http://googlecodesamples.com/