Closed YossiCohen closed 4 years ago
Take a look at oauth / omniauth, specifically with regard to gmail - this will tell you what you have to do.
It is as painful as storing a token for every user, and needing to refresh the user's token every so many hours in order to make requests. It's likely that not using oauth is the reason Google contacted you.
The URL that you don't have a route for is the callback where you should be receiving the oauth tokens - this is a bit outside the scope of the gem and is not a problem with it specifically, but with you not having oauth set up for Gmail/your application.
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.
Sorry if this question is a bit strange but I can't make the xoauth2 work,
I use to send simple email from my app via:
but Google messaged me that I'm not using a secure API, and this method is not recommended by them. I did'nt care about it but then I've noticed that some of my emails are not get sent. so I tried to use the XOAuth2 via
omniauth-google-oauth2
gem but than things started to get complicated.so what I have:
OAuth 2.0 client ID's from the API manager\credentials a.k.a. GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET 2.
config/initializers/omniauth.rb
with content:but when I try to initilize the gmail:
gmail = Gmail.connect(:xoauth2, "myEmail@gmail.com", auth.credentials.token)
I realized that I have no token :-\I've tried to go to :
localhost:3000/auth/google_oauth2
but when I Approve Google's form I get a redirect to:/auth/google_oauth2/callback
but ther is no route defined to that resourcereading about this error got me confused because the answers are reffering it like we want to keep a token for every user in our DB.
All I want is the ability to send emails from my rails application (rails 4.2.6) How can I skip the /auth/google_oauth2 stage and get the token manually? What am I doing wrong?