如何让OAuth访问GMail?

时间:2013-01-01 03:02:13

标签: gmail oauth-2.0 google-oauth

如何让用户启动的访问权限来阅读他们的电子邮件?似乎有OpenID,OAuth,OAuth2和其他随机解决方案。

到目前为止,我提出的最好的是带有scope=https://mail.google.com/的OAuth2。

是否有任何权限只允许我对邮件进行只读访问,并且理想情况下不会通过以下权限通知来吓唬用户:

“查看和管理您的邮件 当我不使用应用程序“

时执行这些操作

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

2 个答案:

答案 0 :(得分:9)

之前的答案不再准确。最近发布的Gmail API允许“只读”和#39;范围等等,可在此处找到:https://developers.google.com/gmail/api/auth/scopes

'只读'范围是:https://www.googleapis.com/auth/gmail.readonly

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.

答案 1 :(得分:4)

The GMail API documentation表示只有一个范围可以访问所有内容。

还有一项名为GMail Inbox Feed的功能可能是您想要的功能,但它仅适用于Google Apps域。