I am tring to log Gdrive in vscode software. And I according the step of url: https://developers.google.com/drive/api/v3/quickstart/nodejs to do it. But when I run step 4 about node . in terminal, this question occured. Can anyone tell me how to solve it.


    PS D:\VScode> node .
    Authorize this app by visiting this url: https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&response_type=code&client_id=668097439811-r1jtctrhhnlptug6ghn3snkpckttokgs.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob
    Enter the code from that page here: 4/1AY0e-g7XilzG82JRv7SNkYA0ou6TdmbIYQqZWpWA1ZzuPq6Fc791-1FxA3o
    Error retrieving access token FetchError: request to https://oauth2.googleapis.com/token failed, reason: read ECONNRESET
        at ClientRequest. (D:\VScode\node_modules\node-fetch\lib\index.js:1461:11)
        at ClientRequest.emit (events.js:315:20)
        at TLSSocket.socketErrorListener (_http_client.js:426:9)
        at TLSSocket.emit (events.js:315:20)
        at emitErrorNT (internal/streams/destroy.js:92:8)
        at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
        at processTicksAndRejections (internal/process/task_queues.js:84:21) {
      type: 'system',
      errno: 'ECONNRESET',
      code: 'ECONNRESET',
      config: {
        method: 'POST',
        url: 'https://oauth2.googleapis.com/token',
        data: 'code=4%2F1AY0e-g7XilzG82JRv7SNkYA0ou6TdmbIYQqZWpWA1ZzuPq6Fc791-1FxA3o&client_id=668097439811-r1jtctrhhnlptug6ghn3snkpckttokgs.apps.googleusercontent.com&client_secret=vmwOLcfpcTVJQMBBILSfprAB&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&grant_type=authorization_code&code_verifier=',
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
          'User-Agent': 'google-api-nodejs-client/3.1.2',
          Accept: 'application/json'
        },
        params: [Object: null prototype] {},
        paramsSerializer: [Function: paramsSerializer],
        body: 'code=4%2F1AY0e-g7XilzG82JRv7SNkYA0ou6TdmbIYQqZWpWA1ZzuPq6Fc791-1FxA3o&client_id=668097439811-r1jtctrhhnlptug6ghn3snkpckttokgs.apps.googleusercontent.com&client_secret=vmwOLcfpcTVJQMBBILSfprAB&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&grant_type=authorization_code&code_verifier=',
        validateStatus: [Function: validateStatus],
        responseType: 'json'
      }
    }

1

There are 1 best solutions below

0
On

You can try to set up your http/https proxy for node CLI env.

process.env.HTTPS_PROXY = 'Your proxy';
google.options({ proxy: 'Your proxy' });