-
-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[New Feature] Support for GMail OAuth tokens #365
Comments
Hi, I started looking a bit into this, but the complicated parts are setting this up myself so i can test. I presume we'd create something like The only problem with this route is it extremely limits the use of Apprise if someone has to to do pre-processing ahead of time. It also makes the I did begin setting myself up following the last link you shared and came faced with this option which also complicates things: I'm not sure how much the setup needs to vary to support both of these options. Which one did you choose for your product? I presume What were your thoughts in how this might be implemented? |
Thank you for looking into this @caronc . Doesn't seem like a trivial thing to implement. Maybe @ncw can offer some guidance based on his successful rsync work on syncing files with Google Drive. |
Doing oauth with google drive is hard - I assume gmail is similar. Setting up the app (client_id/client_secret) and getting it authorized is a real slog. Last time I did it with Google Photos I had to write loads of docs and make a video! Then you have the whole oauth flow which is painful too! If you can use the JSON service files then that makes life a bit easier. |
@ncw thank you for taking the time to comment. I do not have enough direct experience with either and still catching up on docs. This doc seems to offer a clear flow. Maybe apprise should delegate to the app all steps of the flow up to and including the point of obtaining an access token. Apprise only handles the last step of this flow: calling Google APIs with the access token. The app can be also responsible for refreshing the token periodically. So from apprise perspective , it might be a matter of referencing this Google OAuth document and allowing use of OAuth access token as an alternative to the current app password method. |
I hit a bit of a wall... According to the Google documentation, the new way of doing things is to request a After the Token is authorized by you (using the manual intervention), the token to keep your session alive lasts 6 months; Apprise will be clever enough to renew/refresh it before it expires, so this part can be automated from that point forward. The manual part is only required once (but it won't be accepted well - it drives me nuts just thinking about it). This new Gmail adaptation will now the first plugin Apprise has that doesn't work out of the box. Again... unfortunately the limitations are on Googles end, and not Apprise. I start looking to see if we can use a JWT token instead; but from what i read so far, i don't think it's possible. Anyway... that's the long story... the short story is: the code doesn't seem to work. It's as though Google documented the steps to get a Device Token after following through with steps in #1250 but it always returns a For example (Apprise aside), the following should work, but it does not for me (it ALWAYS returns 401 in my case): # Cllient ID is retrieved from: https://console.cloud.google.com/apis/credentials
ClLIENT_ID=12345-xxxxxx.apps.googleusercontent.com
curl -d "client_id=$CLIENT_ID&scope=email" https://oauth2.googleapis.com/device/code I always get (and so does Apprise): {
"error": "invalid_client",
"error_description": "Invalid client type."
} Since i'm blocked now, i can't proceed further on this Any advice would be most appreciated 🙏 |
Currently apprise supports gmail via App Passwords. However Google does not recommend use of app passwords any more.
Instead it recommends App Authorization via OAuth 2.0 or Sign In with Google.
https://support.google.com/accounts/answer/185833?hl=en
Rclone is a reference example of an open source project that uses App Authorization to access Google APIs (gdrive) on behalf of a Google Account user.
https://rclone.org/drive/
The specific use case that prompted this feature request is this: IoT device (Ambianic edge) sending email notification to users, who manage their IoT device via an UI app (Ambianic UI). Via the Google App Authorization flow , users can enable gmail notifications with a few clicks. The UI app will push the gmail authorization code to the IoT device, which will in turn pass it to apprise to obtain a gmail access token to be used in future notification requests from that device.
Google API documentation with the details of this flow:
https://developers.google.com/gmail/api/auth/web-server
The text was updated successfully, but these errors were encountered: