Help me with patreon oauth (getting 400 and 401 error)

hii im creating a mern app, but im getting 400 error and sometimes 401 error after i approve patreon login from browser, this is my express js controller, kindly help me how to fix it?

const linkPatreon = async (req, res) => {
  const code = req.query.code;
  const params = {
    grant_type: "authorization_code",
    client_id: process.env.PATREON_CLIENT_ID,
    client_secret: process.env.PATREON_CLIENT_SECRET,
    redirect_uri: process.env.PATREON_REDIRECT_URI,
  try {
    const tokenResponse = await
    const accessToken =;
    const profileResponse = await axios.get(
        headers: {
          Authorization: `Bearer ${accessToken}`,
          "User-Agent": "sexyprompt",

    return res.status(200).send({ accessToken: });
  } catch (error) {
    return res
      .send({ message: "Error linking account", error: error });

Try to get the request uuid from the response headers so that this can be checked on our side.