I am attempting to use XOauth2 nd the ruby Gmail gem to read email from Google accounts. While I can retrieve a valid token via Oauth, I get an error trying to connect with the token via the Gmail Gem.
I am using OmniAuth to retrieve and store a token, TOKEN. I have confirmed that it is not expired and can be used to connect via Google::APIClient.
When I attempt to connect as follows:
gmail = Gmail.connect(:xoauth2, 'email@gmail.com', :token => TOKEN)
c.login
from the console, I see:
#<Gmail::Client0x7fb037e80988 (email@gmail.com) disconnected>
If I try:
c.login!
I get the error:
Gmail::Client::AuthorizationError: Couldn't login to given Gmail account: email@gmail.com (Invalid credentials (Failure))
Reviewing the Gmail gem source code, it looks like this should work. I am unclear how to debug or what I'm missing.