如何使用OAuth或OAuth2身份验证通过IMAP访问Yahoo Mail [英] How can Yahoo Mail be accessed by IMAP using OAuth or OAuth2 authentication

查看:127
本文介绍了如何使用OAuth或OAuth2身份验证通过IMAP访问Yahoo Mail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据developer.yahoo.com/mail/和IMAP响应:

According to developer.yahoo.com/mail/ and IMAP responses:

* 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

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

Yahoo Mail can be accessed by IMAP using OAuth(2) authentication.

我在 https://developer.yahoo.com/apps/上注册了我的应用,所以我已获得客户ID和客户机密.我没有找到与邮件有关的任何范围(API权限).尽管如此,我还是选择了注册应用程序时显示的所有API权限.

I registered my app on https://developer.yahoo.com/apps/ so I have got Client ID and Client Secret. I didn't find any scopes(API Permissions) related to Mail. Nevertheless I selected all API Permissions which were presented when I registered my app.

我尝试同时实现OAuth和OAuth2.

I tried to implement both OAuth and 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 ),然后在浏览器中打开该页面,并在页面上显示"Developers" :请从注册范围中请求范围,然后再次提交."被陈列.它适用于其他范围.例如,我可以获得"sdct-r"的授权代码

OAuth2: I cannot get the authorization code for scope "mail-r". When I generate URL(https://api.login.yahoo.com/oauth2/request_auth?client_id=CLIENT_ID&redirect_uri=oob&scope=mail-r&response_type=code) and open it in browser, the page with text "Developers: Please request scope from registered scopes and submit again." is displayed. It works for other scopes. For example, I'm able to get the authorization code for "sdct-r"

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

OAuth: I'm able to get an access token. But when I send it with AUTHENTICATE XOAUTH2 command, I get "NO [AUTHENTICATIONFAILED] (#AUTH007) Bad scope" response.

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

So questions is what scope(s) should be set to access Yahoo Mail using IMAP and OAuth(2)?

推荐答案

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

Update February 27, 2017: This work-around will not work anymore as Yahoo has unfortunately taken down the cck-form.html page referenced below and does not seem to allow new apps to request mail related API access. Hopefully this changes.

在这里,您可以在yahoo上创建具有对电子邮件的完全访问权限的应用程序. (最近yahoo从其用户界面中删除了此选项)一旦获得适当的权限,就应该直接获取oauth令牌和访问邮箱,而在此不做介绍.

Here is how you can create an App on yahoo with full access to emails. (recently yahoo remove this option from their UI) once proper permissions are in place, getting oauth tokens and accessing mail boxes should be straight forward and I am not covering it here.

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

  1. Visit https://developer.yahoo.com/oauth/guide/cck-form.html and look for "Here is an example form along with sample values you can use in the form" and copy the example html into a local file and save it. A Copy of the html is available below.

在浏览器中打开文件.填写适当的信息(设置scope = ymrf以获得完整的邮件访问权限),然后单击带调试的弹出窗口".

Open the file on browser. fill appropriate info (set scope=ymrf for full mail access) and click on "pop window with debug".

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

Click on allow on the popup window. Sign in is required if you did not already login to yahoo on the browser.

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

go to https://developer.yahoo.com/apps/ and you should see your app with appropriate permissions.

<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> 

这篇关于如何使用OAuth或OAuth2身份验证通过IMAP访问Yahoo Mail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆