错误:错误:1E08010C:解码器例程::不支持

问题描述 投票:0回答:1

这是我的代码,我尝试与 Google API 建立连接以获取数据并更新 Google Sheet 上的数据。

const { google } = require("googleapis");
const keys = require("./strava-test-credentials.json");

const client = new google.auth.JWT(keys.web.client_email, null, keys.web.key, [
  "https://www.googleapis.com/auth/spreadsheets",
]);

client.authorize(function (err, tokens) {
  gsrun(client);
});
async function gsrun(cl) {
  const gsapi = google.sheets({ version: "v4", auth: cl });

  const opt = {
    spreadsheetId: "1G8W0h8axQLWt-2UmABL72j4y1et3vCB6BpQvg1OUTe0",
    range: "Data!A1:B5",
  };

  let data = await gsapi.spreadsheets.values.get(opt);
  console.log(data.data.values);
}

在运行代码时出现此错误,我尝试了许多解决方案,例如更新node.js并检查时间......

(node:9692) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
node:internal/crypto/sig:128
  const ret = this[kHandle].sign(data, format, type, passphrase, rsaPadding,
                            ^

Error: error:1E08010C:DECODER routines::unsupported
    at Sign.sign (node:internal/crypto/sig:128:29)
    at Object.sign (C:\Users\user\strava-api\node_modules\gtoken\node_modules\jwa\index.js:152:45)
    at Object.jwsSign [as sign] (C:\Users\user\strava-api\node_modules\gtoken\node_modules\jws\lib\sign-stream.js:32:24)
    at GoogleToken.requestToken (C:\Users\user\strava-api\node_modules\gtoken\build\src\index.js:224:31)
    at GoogleToken.getTokenAsyncInner (C:\Users\user\strava-api\node_modules\gtoken\build\src\index.js:158:21)
    at GoogleToken.getTokenAsync (C:\Users\user\strava-api\node_modules\gtoken\build\src\index.js:137:55)
    at GoogleToken.getToken (C:\Users\user\strava-api\node_modules\gtoken\build\src\index.js:96:21)
    at JWT.refreshTokenNoCache (C:\Users\user\strava-api\node_modules\google-auth-library\build\src\auth\jwtclient.js:165:36)
    at JWT.refreshToken (C:\Users\user\strava-api\node_modules\google-auth-library\build\src\auth\oauth2client.js:150:24)
    at JWT.getRequestMetadataAsync (C:\Users\user\strava-api\node_modules\google-auth-library\build\src\auth\oauth2client.js:295:28) {       
  library: 'DECODER routines',
  reason: 'unsupported',
  code: 'ERR_OSSL_UNSUPPORTED'
}

Node.js v21.6.0

我正在努力获取数据和上传数据,

javascript node.js google-api
1个回答
0
投票

在您的本地环境中,您应该将其放在一行中并带有“”:PUBLIC_KEY =“-----BEGIN PUBLIC KEY----- 你的钥匙 -----结束公钥-----"

在部署的环境中,您应该不带“”:PUBLIC_KEY=-----BEGIN PUBLIC KEY----- 你的钥匙 -----结束公钥-----

这对我有用。

© www.soinside.com 2019 - 2024. All rights reserved.