Javascript googleapis包-oAuth2获取令牌返回[无效的\u授予错误请求]

Javascript googleapis包-oAuth2获取令牌返回[无效的\u授予错误请求],javascript,node.js,authentication,Javascript,Node.js,Authentication,我使用的是最新版本的官方google软件包(googleapis),但在获取令牌时,结果是返回400个错误请求: export const googleId = process.env.GOOGLE_CLIENT_ID; export const googleSecret = process.env.GOOGLE_CLIENT_SECRET; export const redirectUrl = `${process.env.PUBLIC_URL}/login/auth`; export co

我使用的是最新版本的官方google软件包(googleapis),但在获取令牌时,结果是返回400个错误请求:

export const googleId = process.env.GOOGLE_CLIENT_ID;
export const googleSecret = process.env.GOOGLE_CLIENT_SECRET;
export const redirectUrl = `${process.env.PUBLIC_URL}/login/auth`;

export const scope = [
  'https://www.googleapis.com/auth/userinfo.email',
  'https://www.googleapis.com/auth/userinfo.profile',
];

export const googleAuthClient = new google.auth.OAuth2(
  googleId,
  googleSecret,
  redirectUrl
);
我已经确保从process.env中正确加载凭据

async login(code: string): Promise<User> {
    const authUrl = this.generate();
    try {
      const {tokens} = await googleAuthClient.getToken(code);
      googleAuthClient.setCredentials(tokens);
    } catch (e) {
      console.log(e);
    }
  }
当然,我省略了答案中的数据,但它们是正确的

有人知道会发生什么吗

我已经把互联网翻了个底朝天,什么也没找到

  response: {
    config: {
      method: 'POST',
      url: 'https://oauth2.googleapis.com/token',
      data: 'code=CODE_HERE&client_id=CLIENT_ID_HERE&client_secret=CLIENT_SECRET_HERE&redirect_uri=REDIRECT_URL_HERE&grant_type=authorization_code&code_verifier=',
      headers: [Object],
      paramsSerializer: [Function: paramsSerializer],
      validateStatus: [Function: validateStatus],
      responseType: 'json'
    },
    data: { error: 'invalid_grant', error_description: 'Bad Request' },
    headers: {
      'alt-svc': 'h3-29=":443"; ma=2592000,h3-T051=":443"; ma=2592000,h3-Q050=":443"; ma=2592000,h3-Q046=":443"; ma=2592000,h3-Q043=":443"; ma=2592000,quic=":443"; ma=2592000; v="46,43"',
      'cache-control': 'no-cache, no-store, max-age=0, must-revalidate',
      connection: 'close',
      'content-encoding': 'gzip',
      'content-type': 'application/json; charset=utf-8',
      date: 'Fri, 28 May 2021 18:44:07 GMT',
      expires: 'Mon, 01 Jan 1990 00:00:00 GMT',
      pragma: 'no-cache',
      server: 'scaffolding on HTTPServer2',
      'transfer-encoding': 'chunked',
      vary: 'Origin, X-Origin, Referer',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'SAMEORIGIN',
      'x-xss-protection': '0'
    },
    status: 400,
    statusText: 'Bad Request',
    request: { responseURL: 'https://oauth2.googleapis.com/token' }
  },