如何让OAuth访问GMail?

如何让OAuth访问GMail?,gmail,oauth-2.0,google-oauth,Gmail,Oauth 2.0,Google Oauth,您如何获得用户发起的访问权限来阅读他们的电子邮件?似乎有OpenID、OAuth、OAuth2和其他随机解决方案 到目前为止,我想到的最好的是OAuth2,它具有范围=https://mail.google.com/ 是否有任何权限只允许我以只读方式访问邮件,理想情况下不会用如下权限通知吓唬用户: “查看和管理您的邮件 在不使用应用程序时执行这些操作“ 如果可能的话,我只想“查看您的邮件”。说只有一个作用域可以访问所有内容 还有一个功能叫做,它可能是你想要的,但它只在谷歌应用程序域上可用。前面的

您如何获得用户发起的访问权限来阅读他们的电子邮件?似乎有OpenID、OAuth、OAuth2和其他随机解决方案

到目前为止,我想到的最好的是OAuth2,它具有
范围=https://mail.google.com/

是否有任何权限只允许我以只读方式访问邮件,理想情况下不会用如下权限通知吓唬用户:

“查看和管理您的邮件 在不使用应用程序时执行这些操作“

如果可能的话,我只想“查看您的邮件”。

说只有一个作用域可以访问所有内容


还有一个功能叫做,它可能是你想要的,但它只在谷歌应用程序域上可用。

前面的答案不再准确。最近发布的Gmail API允许一个“只读”范围,可以在这里找到

“只读”范围是:


如果用户愿意,在答案中发布链接对于进一步阅读非常有用,但您也应该在答案中总结链接内容。如果链接被破坏,你的答案仍然需要有用。这篇文章要求Gmail API的“只读”范围。我单独提供了作用域,并提供了指向所有其他作用域的链接。碰巧这篇文章要求的是一个https链接。谢谢你更新的答案。只是一个问题;你知道在我的应用程序获得用户许可后如何实际获取电子邮件吗?由“”返回的令牌与MailMan不起作用。
https://www.googleapis.com/auth/gmail.readonly
Read all resources and their metadata—no write operations.

https://www.googleapis.com/auth/gmail.compose
Create, read, update, and delete drafts. Send messages and drafts.

https://www.googleapis.com/auth/gmail.send
Send messages only. No read or modify privileges on mailbox.

https://www.googleapis.com/auth/gmail.insert
Insert and import messages only.

https://www.googleapis.com/auth/gmail.labels
Create, read, update, and delete labels only.

https://www.googleapis.com/auth/gmail.modify
All read/write operations except immediate, permanent deletion of threads and messages, bypassing Trash.

https://www.googleapis.com/auth/gmail.metadata
Read resources metadata including labels, history records, and email message headers, but not the message body or attachments.

https://www.googleapis.com/auth/gmail.settings.basic
Manage basic mail settings.

https://www.googleapis.com/auth/gmail.settings.sharing
Manage sensitive mail settings, including forwarding rules and aliases. 

Note: Operations guarded by this scope are restricted to administrative use only. They are only available to G Suite customers using a service account with domain-wide delegation. 

https://mail.google.com/
Full access to the account, including permanent deletion of threads and messages. This scope should only be requested if your application needs to immediately and permanently delete threads and messages, bypassing Trash; all other actions can be performed with less permissive scopes.