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

查看:46
本文介绍了IMAP 如何使用 OAuth 或 OAuth2 身份验证访问 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) Bad scope"响应.

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 上创建具有电子邮件完全访问权限的应用程序.(最近雅虎从他们的用户界面中删除了这个选项)一旦适当的权限到位,获取 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".

点击弹出窗口中的允许.如果您尚未在浏览器上登录雅虎,则需要登录.

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> 

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

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