Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cmesav opened this issue Jan 31, 2023 · 5 comments

Comments

@cmesav
Copy link

cmesav commented Jan 31, 2023

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 cmesav closed this as completed Jan 31, 2023
@cmesav cmesav reopened this Jan 31, 2023
@levz0r
Copy link
Owner

levz0r commented Jan 31, 2023

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

@digitalgopnik
Copy link

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

@madhurich
Copy link

madhurich commented Apr 5, 2023

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
Copy link

madhurich commented Apr 12, 2023

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.

@larxn
Copy link

larxn commented Apr 11, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants