IMAP如何使用OAuth或OAuth2身份验证访问Yahoo Mail

Ale*_*sey 6 imap oauth yahoo-mail oauth-2.0 yahoo-oauth

根据developer.yahoo.com/mail/和IMAP回复:

* OK [CAPABILITY IMAP4rev1 ID MOVE NAMESPACE X-ID-ACLID UIDPLUS LITERAL+ CHILDREN XAPPLEPUSHSERVICE XYMHIGHESTMODSEQ AUTH=PLAIN AUTH=LOGIN AUTH=XOAUTH2 AUTH=XYMCOOKIE AUTH=XYMECOOKIE AUTH=XYMCOOKIEB64 AUTH=XYMPKI] IMAP4rev1 imapgate-1.8.1_01.20166 imap1009.mail.ne1.yahoo.com
Run Code Online (Sandbox Code Playgroud)

IMAP可以使用OAuth(2)身份验证访问Yahoo Mail.

我在https://developer.yahoo.com/apps/上注册了我的应用程序,因此我获得了客户端ID和客户端密钥.我没有找到任何与Mail相关的范围(API权限).不过,我选择了在注册我的应用程序时显示的所有API权限.

我试图实现OAuth和OAuth2.

OAuth2:我无法获取范围"mail-r"的授权码.当我生成URL(https://api.login.yahoo.com/oauth2/request_auth?client_id=CLIENT_ID&redirect_uri=oob&scope=mail-r&response_type=code)并在浏览器中打开它时,带有文本的页面"开发者:请从注册范围并再次提交." 被展示.它适用于其他范围.例如,我可以获取"sdct-r"的授权码

OAuth:我能够获得访问令牌.但是当我使用AUTHENTICATE XOAUTH2命令发送它时,我得到"NO [AUTHENTICATIONFAILED](#AUTH007)Bad scope"响应.

那么问题是应该设置哪些范围来使用IMAP和OAuth(2)访问Yahoo Mail?

小智 11

2017年2月27日更新:由于雅虎不幸删除了下面引用的cck-form.html页面并且似乎不允许新应用程序请求与邮件相关的API访问,因此这种解决方法将不再适用.希望这会改变.

以下是如何在雅虎上创建一个完全访问电子邮件的应用程序.(最近雅虎从他们的用户界面删除此选项)一旦适当的权限到位,获得oauth令牌和访问邮箱应该是直截了当的,我不在这里覆盖它.

  1. 访问https://developer.yahoo.com/oauth/guide/cck-form.html并查找"这是一个示例表单以及您可以在表单中使用的示例值",并将示例html复制到本地文件中保存.下面提供了html的副本.

  2. 在浏览器上打开文件.填写适当的信息(设置范围= ymrf进行完整的邮件访问),然后单击"弹出窗口调试".

  3. 单击弹出窗口中的allow.如果您尚未在浏览器上登录yahoo,则需要登录.

转到https://developer.yahoo.com/apps/,您应该会看到具有适当权限的应用.

<html>  
<head>  
    <title>CCK Example</title>  
</head>  
<body>  
  
<form target="yCredWindow" action="http://developer.apps.yahoo.com/projects/createconsumerkey" method="post" id="extAuthForm" name="extAuthForm">  
  
<h2>Inputs</h2>  
<p>* = Required</p>    
<table>  
    <tr><th>Field</th>  
        <th>Input</th></tr>  
  
    <tr><td>* Application Name: </td>  
        <td><input name="name" id="name" value="Janrain Engage"></td></tr>  
  
    <tr><td>Description: </td>  
        <td><input name="description" id="desc"></td></tr>  
  
    <tr><td>appid: </td>  
        <td><input name="appid" id="appid"></td></tr>  
  
    <tr><td>Return to: </td>  
        <td><input name="return_to" id="return_to"></td></tr>  
  
    <tr><td>* Third Party Name: </td>  
        <td><input name="third_party" id="third_party" value="Janrain"></td></tr>  
  
    <tr><td>* Scopes: </td>  
        <td><input name="scopes" id="scope" value="ysrw"></td></tr>  
  
    <tr><td>Favicon URL: </td>  
        <td><input name="favicon" id="favicon"></td></tr>  
  
    <tr><td>Application URL: </td>  
        <td><input name="application_url" id="application_url"></td></tr>  
  
    <tr><td>* Domain: </td>  
        <td><input name="domain" id="domain" value="www.janrain.com"></td></tr></table>  
  
<input type="hidden" name="debug" id="debug" value="true">  
  
<button type="reset">clear all fields</button>  
<button type="button" id="submitWithDebug">pop window with debug</button>  
</form>  
  
<h6>Note: A URL that starts with http:// is required for: Return to, Favicon URL and Application URL.  However, you will get an error if you include http:// for the Domain.</h6>  
  
<h2>Returns</h2>  
<table>  
    <tr><td>Key returned:</td>  
        <td><input type="text" id="cKeyInputField"></td></tr>  
  
    <tr><td>Secret returned:</td>  
        <td><input type="text" id="cSecretInputField"></td></tr>  
  
    <tr><td>Appid returned:</td>  
        <td><input type="text" id="returnAppid"></td></tr></table>  
  
<script src="http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js"></script>  
<script>  
  
var formTarget = null;  
  
// used by return_to.html to set the fields with the data that comes back  
var setFields = function(id, val)  { document.getElementById(id).value = val; };  
  
// pops the window, then submits to it  
var popWindowOnSubmit = function(e)  {  
    window.open('', formTarget, 'status=0,toolbar=0,location=0,menubar=0,width=545,height=650');  
    document.extAuthForm.submit();  
};  
  
// handle submit when the button is clicked  
YUI().use('node', function(Y) {  
    formObject = Y.one('#extAuthForm');  
    formTarget = formObject.getAttribute('target');  
    Y.on('click', popWindowOnSubmit, '#submitWithDebug');  
});  
  
</script>  
  
</body>  
</html> 
Run Code Online (Sandbox Code Playgroud)

  • 此解决方法现在不起作用.在调试模式窗口中打开弹出窗口时,尝试打开https://developer.yahoo.com/projects/createconsumerkey/并失败,状态为404.还有其他解决方法吗? (4认同)