@auth0/nextjs-auth0 getAccessToken Error

Hello,

I am working on implementing some logic into my nextjs endpoints that refreshes an api access token using a refresh token when the current token has expired. Here is a sample of my current code:

import {
  getAccessToken,
  withApiAuthRequired,
} from '@auth0/nextjs-auth0';
import { NextApiRequest, NextApiResponse } from 'next';
import afterRefresh from '../../../../utils/helpers/afterRefresh';

export default withApiAuthRequired(
  async (req: NextApiRequest, res: NextApiResponse) => {
    const { accessToken } = await getAccessToken(req, res, {
      refresh: true,
      afterRefresh,
    });
    try {
      const { body } = req;
      const result = await fetch(
        `${process.env.API_URI}/invitations/meetings`,
        {
          headers: {
            Authorization: `Bearer ${accessToken}`,
            'Content-Type': 'application/json',
          },
          method: 'POST',
          body: body,
        }
      );
      const data = await result.json();
      return res.status(200).json(data);
    } catch (err) {
      return res.status(500).json({
        error: 'There was an error',
        message: err,
      });
    }
  }
);

During the call to getAccessToken() I am getting this error:

error - [Error [AccessTokenError]: The request to refresh the access token failed. CAUSE: access_denied (The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined)] {
digest: undefined

Any help regarding this error would be very helpful. I am getting a valid refresh token and the NextApiRequest + NextApiResponse objects that are being sent to the getAccessToken function appear to be formed correctly. Thank you!