Freshdesk Oauth SSO:访问 Freshdesk 重定向 URI 时出现 CORS 错误? [英] Freshdesk Oauth SSO: CORS Error on Accessing Freshdesk Redirect URI?

查看:40
本文介绍了Freshdesk Oauth SSO:访问 Freshdesk 重定向 URI 时出现 CORS 错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Freshdesk 设置 OAuth SSO.我希望我的应用的用户能够登录我的 Freshdesk 支持站点,而无需创建新的用户名/密码.

I'm setting up OAuth SSO for Freshdesk. I want the user of my app to be able to login to my Freshdesk support site, without having to create a new username/password.

到目前为止,以下步骤有效:

So far the following steps work:

  • 我的网站用户点击支持"按钮菜单项
  • Freshdesk SSO 登录页面出现
  • 我的用户点击客户端登录"那里
  • Freshdesk 使用我的应用正确处理的 GET 请求访问我的授权网址
  • Freshdesk 向我的同一个授权 URL 发送一个 OPTIONS 请求,我对此不做任何处理(除了调用 next())
  • Freshdesk 使用包含 redirect_uri
  • 的 POST 请求访问我的相同授权 URL
  • My site user clicks a "Support" menu item
  • The Freshdesk SSO login page comes up
  • My user clicks "client login" there
  • Freshdesk hits my Authorization URL with a GET request which my app handles correctly
  • Freshdesk hits my same Authorization URL an OPTIONS request which I don't do anything with (other than calling next())
  • Freshdesk hits my same Authorization URL with a POST request containing a redirect_uri

这就是我遇到麻烦的时候.我的服务器需要向 Freshdesk 提供的 redirect_uri 发送一些信息,我收到了 CORS 错误.

This is when I get into trouble. My server needs to send some info to the redirect_uri provided by Freshdesk, and I get a CORS error.

这是我的服务器代码:

    const clientId = req.body.client_id;
    const code = Random.secret();

    const q = new URLSearchParams({
        code: code,
        user: user._id,
        state: req.body.state
    })

    const finalRedirectUri = `${req.body.redirect_uri}?${q}`
    console.info(finalRedirectUri)
    const headers = {
        'Access-Control-Allow-Origin': '*'
    }
    res.writeHead(302, { headers, Location: finalRedirectUri})
    res.end()

错误信息如下:

我该如何解决这个问题?

How do I fix this?

推荐答案

我认为我的帐户设置中 Freshdesk 方面存在错误.理论:当我第一次创建我的 Freshdesk 帐户时,我使用了默认 URL.后来我要求更改它们以反映我的应用程序名称,而 Freshdesk 进行了更改.可能他们当时错过了更新某些配置.

I think there was a bug on the Freshdesk side in the setup for my account. Theory: when I first created my Freshdesk account, I used the default URLs. Later I asked to change them to reflect my app name and Freshdesk made changes. It may be possible that they missed updating some configs at that time.

我已转到更适合我的应用的其他帮助台.

I've moved on to a different Help Desk that is more suitable for my app.

这篇关于Freshdesk Oauth SSO:访问 Freshdesk 重定向 URI 时出现 CORS 错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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