gmail-tester icon indicating copy to clipboard operation
gmail-tester copied to clipboard

error while executing the command "node node_modules/gmail-tester/init.js credentials.json token.json [email protected]"

Open cmesav opened this issue 2 years ago • 5 comments

I am trying to use gmail-tester, I have downloaded the credentials.json following the steps indicated in the documentation, but when I run the command, the tokenjson is not created and the error comes out:


[gmail] Checking for message from '', to: [email protected], contains '' in subject... 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%2Fgmail.readonly&response_type=code&client_id={clientId}&redirect_uri=http%3A%2F%2Flocalhost node:events:491 throw er; // Unhandled 'error' event ^

Error: listen EADDRINUSE: address already in use :::80 at Server.setupListenHandle [as _listen2] (node:net:1485:16) at listenInCluster (node:net:1533:12) at Server.listen (node:net:1621:7) at /Users/{user}//Documents/POC Cypress/node_modules/gmail-tester/libs/oauth2.js:60:10 at new Promise () at authenticate (/Users/{user}/Documents/POC Cypress/node_modules/gmail-tester/libs/oauth2.js:36:10) at get_new_token (/Users/{user}/Documents/POC Cypress/node_modules/gmail-tester/gmail.js:47:10) at Object.authorize (/Users/{user}/Documents/POC Cypress/node_modules/gmail-tester/gmail.js:30:35) at _get_recent_email (/Users/{user}/Documents/POC Cypress/node_modules/gmail-tester/gmail-tester.js:38:36) at __check_inbox (/Users/{user}/Documents/POC Cypress/node_modules/gmail-tester/gmail-tester.js:108:28) Emitted 'error' event on Server instance at: at emitErrorNT (node:net:1512:8) at process.processTicksAndRejections (node:internal/process/task_queues:82:21) { code: 'EADDRINUSE', errno: -48, syscall: 'listen', address: '::', port: 80 }


never asks to enter the code, the url takes me to the code site, but it does not leave where to put it, credentials.json file are located in cypress root folder, cypress version 12.4.1.

Can anyone help me what I’m doing wrong? thank you.

cmesav avatar Jan 31 '23 02:01 cmesav

Looks like you're running a server on port 80. Try stopping it while running init.js.

levz0r avatar Jan 31 '23 23:01 levz0r

I'm having a similar issue, but my port is not already in use, i have just permission denied 0.0.0.0:80.

node:events:491
      throw er; // Unhandled 'error' event
      ^

Error: listen EACCES: permission denied 0.0.0.0:80
    at Server.setupListenHandle [as _listen2] (node:net:1716:21)
    at listenInCluster (node:net:1781:12)
    at Server.listen (node:net:1869:7)
    at /home/chra/Dev/shop/sw6/node_modules/gmail-tester/libs/oauth2.js:60:10
    at new Promise (<anonymous>)
    at authenticate (/home/chra/Dev/shop/sw6/node_modules/gmail-tester/libs/oauth2.js:36:10)
    at get_new_token (/home/chra/Dev/shop/sw6/node_modules/gmail-tester/gmail.js:47:10)
    at Object.authorize (/home/chra/Dev/shop/sw6/node_modules/gmail-tester/gmail.js:30:35)
    at _get_recent_email (/home/chra/Dev/shop/sw6/node_modules/gmail-tester/gmail-tester.js:38:36)
    at __check_inbox (/home/chra/Dev/shop/sw6/node_modules/gmail-tester/gmail-tester.js:108:28)
Emitted 'error' event on Server instance at:
    at emitErrorNT (node:net:1760:8)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
  code: 'EACCES',
  errno: -13,
  syscall: 'listen',
  address: '0.0.0.0',
  port: 80
}

Node.js v18.13.0

Simply can be fixed when executing the init.js-command as sudo -> see this or workaround

digitalgopnik avatar Feb 16 '23 21:02 digitalgopnik

I am facing similar issue where it doesn't ask me to enter the code, however I am not seeing any errors. Initially I set up this on a laptop and I got a new laptop, then setup all the required tools on my new laptop it doesn't ask me to enter the code on my new laptop.

image

cypress - 10.11.0 NodeJS - 16.13.0

Could someone please help me here

madhurich avatar Apr 05 '23 16:04 madhurich

I am facing similar issue where it doesn't ask me to enter the code, however I am not seeing any errors. Initially I set up this on a laptop and I got a new laptop, then setup all the required tools on my new laptop it doesn't ask me to enter the code on my new laptop.

image

cypress - 10.11.0 NodeJS - 16.13.0

Could someone please help me here

I was able to figure this out, by removing this "urn:ietf:wg:oauth:2.0:oob" value from redirect_uris array from my credentials.json file and only have "http://localhost", then try generating the token. With this there will not be the step to paste the token from the browser to terminal, instead once the command for token generation is ran there will be a message "gmail Found" and gmail_token.json file (or whatever the filename is put while token generation) is generated.

madhurich avatar Apr 12 '23 20:04 madhurich

Running something on port 80 usually requires root level access, so you can either run it with sudo or grant low-numbered port access to Node:

sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/bin/node

(Once gmail-tester generates a local token file, sudo is not required).

Credits to this StackOverflow answer.

larxn avatar Apr 11 '24 21:04 larxn