levz0r / gmail-tester

A simple Node.js Gmail client which checks the inbox for message existence
MIT License
256 stars 68 forks source link

Asking for code in console during test execution #101

Closed f1348y73 closed 2 years ago

f1348y73 commented 2 years ago

Hello everyone,

I'm currently looking for ways to check emails within cypress and came across this library. Since I encountered a problem in my test project, I thought it might be due to the cypress version (10.3.1). So I cloned the gmail-tester repository and tried the cypress example inside. Steps:

If I now run gmail.spec.js the console shows (see last line): : 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= 94167587089-mclmf5ic7i2uk8sbtv0v1umvq1rcju9b.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob Enter the code from that page here: :

Here the console stops and the cypress test runs into a timeout. I have this behavior in my test project with Cypress V. 10.3.1 and gmail-test ^1.3.5 but also in the example project from https://github.com/levz0r/gmail-tester with Cypress ^5.1.0 and gmail- testing ^1.3.5.

Does anyone know what I'm doing wrong?

One more point: There is a ticket here from 07/22/2022 Title: localhost redirect (https://github.com/levz0r/gmail-tester/issues/97). Is it maybe because of the credentials.json? In each example, after the download, the JSON file contains: "redirect_uris": [ "urn:ietf:wg:oauth:2.0:oob", "http://localhost" ] If I download the JSON file, urn:ietf:wg:oauth:2.0:oob is not included and I enter it manually. Without this entry I had the same behavior as https://github.com/levz0r/gmail-tester/issues/97

So maybe it's because of that or something else? I'm grateful for any advice!

Best regards

f1348y73 commented 2 years ago

Hello, ok, shame on me! This is what happens when you copy too much.

  1. In the example code, the filename of the token is 'token.json'. However, I generated a 'gmail_token.json' and of course did not adapt the code.
  2. It has nothing to do with the entry (urn:ietf:wg:oauth:2.0:oob). If the entry is available, you get to '...accounts.google.com...' and can copy the token from there. Without this entry you get to '...localhost/...' with 'ERR_CONNECTION_REFUSED'. However, the token is included in the URL (...localhost/code=4/0AdQt8...bQ&scope= https ://www.googleapis.com/auth/gmail.readonly)

BR

1112shivam commented 2 years ago

how much time does it take to start reading emails from your inbox after setting this up? I also got the same localhost error, I copied the code from URL and passed it to the requested place.