【发布时间】:2021-01-28 21:49:10
【问题描述】:
这里有点撞墙。我将我的回调域设置为我的 ngrok 实例(付费帐户)。我对 Yahoo 身份验证的重定向请求如下所示:
"https://api.login.yahoo.com/oauth2/request_auth?client_id=fakeclientid--&redirect_uri=https://myname.ngrok.io/api/authentication_handler&response_type=code&language=en-us"
我正在重定向到那个:
return new RedirectResult(yahooOauthUrl);
我正确地被重定向,输入我的凭据,登录到雅虎,但我在雅虎这边看到了一个屏幕:
如果我在邮递员中或通过 Chrome 公开向我的重定向 URI 提交 GET/POST 请求,我会收到一个访问本地主机的请求。我还验证了我的 Yahoo 应用具有完全相同的回调域:
myname.ngrok.io
处理我的回调请求的代码在这里:
// GET/POST api/authentication_handler
[HttpGet]
[Route("/api/authentication_handler")]
public HttpResponseMessage HandleAuthentication(string code)
{
return string.IsNullOrWhiteSpace(code)
? new HttpResponseMessage(HttpStatusCode.InternalServerError)
: new HttpResponseMessage(HttpStatusCode.OK);
}
我错过了什么明显的东西吗?
【问题讨论】:
-
你需要将
https://myname.ngrok.io/api/authentication_handlerurl编码为https%3A%2F%2Fmyname.ngrok.io%2Fapi%2Fauthentication_handler -
如果你在
HandleAuthentication中设置一个断点,它会被命中吗? -
看起来 RedirectResult 已经在对其进行编码,但我会明确地尝试一下,不,HandleAuthentication 永远不会被命中。
-
It looks like the RedirectResult is already encoding it是什么让你相信? -
@mjwills 我可以在填写 Yahoo auth 表单时看到编码的 RedirectUri。它在那里看起来完全正确,但甚至从未尝试重定向回来。在开发者工具控制台中查看它的 chrome,它永远不会尝试另一个 302。
标签: c# asp.net-web-api oauth asp.net-core-webapi yahoo-api