Zendesk OAuth“无效的授权请求”

时间:2019-05-21 15:16:11

标签: zendesk-api

我正在尝试通过OAuth 2.0实现Zendesk集成。当我重定向到登录页面时,出现错误:“无效的授权请求”和“错误的请求”。

我的重定向网址:

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

1 个答案:

答案 0 :(得分:0)

它可能与重定向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
        }

    }