Closed maartenvanrijn closed 4 years ago
I don't use xoauth. @gmailgem/owners can anybody assist?
Hi, I am having trouble using this gem with oauth2 set up. I am using Ruby on Rails with Rails 4.2.1 My Gemfile looks like this: ... gem 'omniauth-google-oauth2' gem 'oauth2' gem 'google-api-client' gem 'gmail', :require => true, git: "https://github.com/gmailgem/gmail.git" ... In a controller, I do ... gmail = Gmail.connect(:xoauth2, @user.email.to_s, :oauth2_token => @user.token.to_s) ... I then proceed to do 'gmail.inbox.count', where I get the following error:
Net::IMAP::BadResponseError. Unknown command dh9mb210919324pdb
Extracted source (around line #13): 12 gmail = Gmail.connect(:xoauth2, @user.email.to_s, :oauth2_token => @user.token.to_s) 13 @test = gmail.inbox.count 14 end 15 end
It says you guys added support for xoauth2, but I'm not sure how to use it with the Gmail.connect(...) Is what I'm trying to do even possible right now?
Thanks,
Try using gmail = Gmail.connect(:xoauth2, email, token => "my_access_token").
@PranayPant Hey, did this work? I am facing the same issue. Gmail object I get is disconnected, <Gmail::Client0x7fe9b1cb4ec0 (sudhagar@gmail.com) disconnected>
I am using, gmail = Gmail.connect( :xoauth2, auth[:info][:email], :token => auth[:credentials][:token], )
Looking at the source code, there is no need for hash param there. So just Gmail.connect(:xoauth2, email, oauth_token) would work.
I 'm using gem google-api-client
instead of this. I found it better (and usable - couldn't figure out OAuth 2.0 connection with other gems).
Using Gmail.connect(:xoauth2, email, oauth_token) I'm getting disconnected object as well.
@johnnyshields Hi, any idea why this is failing?
@SudhagarS it seems that the main gem gmail_xoauth might be the issue. I wasn't able to get it to work with that as well. The solution for me was to use google-api-client and make sure correct APIs are enabled in Google API console.
@gonchs Thanks for the info. I really like the interface in this library and google libraries seems over engineered to me.
Still no solution here? This gem is essentially unusable until somebody fixes this. Nobody is going to use an app that makes you set access for less secure apps to true.
@robins35 we could use your help to debug this. I would recommend to start by determining whether the problem lies in this library or in https://github.com/nfo/gmail_xoauth, which is a dependency of this library.
I can't get auth to work either with OAuth, essentially rendering this gem useless.
What is the error you get when you use the verbose / exception-throwing connect! method?
Any update on this? I'm also getting the <Gmail::Client{{numbers}} ({{email}}) disconnected>
I'm also still getting the <Gmail::Client{{numbers}} ({{email}}) disconnected>.
Man this issue has been there for a loooooooong time...time to switch platforms you guys!
As of version 0.7.0 (Aug 19, 2018) this gem is officially deprecated and will no longer be maintained. Please instead use Google's official Gmail API Ruby Client, which uses the Gmail API rather than IMAP and has significantly better performance and reliability.
Hey all,
I have set up oauth2. I can connect my gmail account to it / authenticate with my google account. When using the xoauth gem I can connect using imap.authenticate('XOAUTH2', email, access_token) However, I cannot connect using gmail = Gmail.connect(:xoauth, email, access_token)
I don't have a 'secret', 'consumer_key', 'consumer_secret' nor do I need any when connecting using the imap.authenticate method.
What am I not seeing / doing wrong?