I want to get oauth or xauth tokens from GMail to use with gmail-oauth. I'm thinking of using OmniAuth but it seems not to support GMail yet, which means that with stock OmniAuth is impossible. Is that correct? Am I missing something?
相关问题
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
- reference to a method?
- ruby 1.9 wrong file encoding on windows
- gem cleanup shows error: Unable to uninstall bundl
相关文章
- Ruby using wrong version of openssl
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- “No explicit conversion of Symbol into String” for
- Segmentation fault with ruby 2.0.0p247 leading to
- How to detect if an element exists in Watir
- uninitialized constant Mysql2::Client::SECURE_CONN
- ruby - simplify string multiply concatenation
I had trouble, like you, using existing gems with OAuth2 and Gmail since Google's OAuth1 protocol is now deprecated and many gems have not yet updated to use their OAuth2 protocol. I was finally able to get it to work using
Net::IMAP
directly.Here is a working example of fetching email from Google using the OAuth2 protocol. This example uses the
mail
,gmail_xoauth
,omniauth
, andomniauth-google-oauth2
gems.You will also need to register your app in Google's API console in order to get your API tokens.
Omniauth has support for both OAuth and OAuth2, which will both allow you to authenticate a google account.
Here are all of the strategies you can use via omniauth: https://github.com/intridea/omniauth/wiki/List-of-Strategies
Here are the two google OAuth gems:
As per the documentation of the first gem:
Add the middleware to a Rails app in config/initializers/omniauth.rb:
This is done in addition to setting up the main omniauth gem.