简体   繁体   中英

Javascript; Server-less retrieving of unread emails with Gmail API

Thanks to OAuth2 many APIs are accessible from client side without any server.

I'm trying to do that with the unread emails in Gmail.

With the OAuth2 playground it is possible to achieve that. However my attempts are not successful (see reply). I wonder if my attempts have been exhaustive and there is no way to achieve my goal or if I looked over a possibility?

According to the official Gmail API doc there are two ways to access emails:

Browsers doesn't provide access to TCP to JavaScript and therefore IMAP/SMTP will not help here.

After trying, the server behind https://mail.google.com/mail/feed/atom doesn't seem to support CORS. So no luck here neither.

Apparently, a server is needed (or something like packaged apps that gives TCP access )

The new Gmail API lets you exactly do that;

https://developers.google.com/gmail/api/

It uses OAuth 2 and a JavaScript wrapper library

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM