2013-01-01 91 views
10

如何獲得用戶發起的閱讀他們的電子郵件?看來有OpenID,OAuth,OAuth2和隨機的其他解決方案。如何讓OAuth訪問GMail?

到目前爲止我所得出的最好結果是OAuth2與scope=https://mail.google.com/

是否有隻給我只讀到郵件訪問和理想不是像許可通知嚇唬用戶的任何權限:

「查看和管理您的郵件 當我執行這些操作不使用應用程序「

所有我想,如果可能的話」查看您的郵件「。

回答

9

上一個答案不再準確。最近發佈的Gmail API允許使用「只讀」範圍,其中包括: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

在你的答案發帖鏈接是偉大的進一步閱讀,如果用戶想,但你應該總結你的答案被鏈接的內容,以及。如果鏈接被破壞,您的答案仍然有用。 – skrrgwasme

+3

該帖子向Gmail API請求「只讀」範圍。我單獨提供了範圍,並提供了所有其他範圍的鏈接。恰恰相反,帖子要求的是https鏈接。 – eugene1832

+0

感謝您的更新答案。就一個問題;你知道如何在我的應用程序獲得用戶許可後真正獲得電子郵件嗎? – kramer65