Zendesk OAuth "Invalid Authorization Request"

Zendesk OAuth "Invalid Authorization Request"

我正在尝试通过 OAuth 2.0 实现 Zendesk 集成。当我重定向到登录页面时,出现错误:"Invalid Authorization Request" 和 "bad request"。

我的重定向 url:

            string redirectUrl = $"https://{subdomain}.zendesk.com/oauth/authorizations/new?response_type=code&redirect_uri={redirectUri}&client_id={client_id}&scope=read";

可能与重定向有关url。 Zendesk 似乎要求重定向 url 与您从中重定向到 Zendesk 的 url 完全相同。在 ASP .NET Core WebApi 中,可以通过使用一种 api 方法来解决重定向到 Zendesk 和接收重定向的问题。像这样:

[Route("[action]")]
    public IActionResult Authorize()
    {
        if (!Request.Query.ContainsKey("code"))
        {
            string redirectUrl = $"https://{subdomain}.zendesk.com/oauth/authorizations/new?response_type=code&redirect_uri={redirectUri}&client_id={client_id}&scope=read";
            return Redirect(redirectUrl);
        }
        else
        {
            var code = Request.Query["code"];
            //your code here
        }

    }