levz0r / gmail-tester

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

Created a new project on Google Console, Get the Credentials but the init process never ends #127

Open rgrlaika opened 1 year ago

rgrlaika commented 1 year ago

I noticed that google apis deprecated the Out-Of-Band (OOB) which means that credentials created now does not have the urn:ietf:wg:oauth:2.0:oob it creates with "redirect_uris":["http://localhost/"]}}

Then I was trying to run the node node_modules/gmail-tester/init.js cypress/events/gmail/credentials.json cypress/events/gmail/gmail_token.json <account@gmail.com>

Note: the actual email has been omitted

Then it directly opened the page to grant the email and redirected to the : localhost asking to back to the terminal

Screenshot 2023-02-07 at 15 42 44

I back to the terminal but what I had was the prompt below forever:

[gmail] Checking for message from '', to: account@gmail.com, contains '' in subject... Note: I never asks me to put a code in the terminal

I think it has something to do with the deprecation of Out-Of-Band (OOB) https://developers.google.com/identity/protocols/oauth2/resources/oob-migration

I tried to use the latest version of gmail-tester and it does not work.

Indeed it creates the file gmail_token.json (in my case) but if I delete it, when running the tests it opens a new instance of the browser during the cypress test execution, and asks to grant the permission for the email again, hence a manual intervention needed.

Any idea if it's a known issue if it's a workaround?

I also noticed people complaining it here without any answers:

https://github.com/levz0r/gmail-tester/issues/73

hieuTranEnouvo commented 1 year ago

I still get the issue above error": { "code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "errors": [ { "message": "Login Required.", "domain": "global", "reason": "required", "location": "Authorization", "locationType": "header" } ], "status": "UNAUTHENTICATED", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "CREDENTIALS_MISSING", "domain": "googleapis.com", "metadata": { "method": "caribou.api.proto.MailboxService.GetMessage", "service": "gmail.googleapis.com" } } ] }

azadnsu commented 1 year ago

@hieuTranEnouvo For me, it works all good. Have you placed credentials.json correctly in the path you are pointing?

I tried gmail-tester v1.3.8 , yes it does not ask to enter code now but this is more better. You don't need to enter code now, it automatically gets authenticated! Screenshot 2023-03-08 at 19 11 09

NighatAtta commented 1 year ago

@azadnsu I am facing the same issue as above. In my case it is giving me the following error: FetchError: request to https://gmail.googleapis.com/gmail/v1/users/me/messages/181dc6b25056f876?format=full failed, reason: connect ETIMEDOUT 216.58.209.138:443 Do you have any idea about this? Any help would be appreciated. 2023-03-10 (4)

hieuTranEnouvo commented 1 year ago

@azadnsu The issue still display. It doesn't enter code automatically Screenshot 2023-03-10 at 14 42 51

azadnsu commented 1 year ago

@hieuTranEnouvo See your account is actually set up successfully, otherwise, it won't go for email search. Now, regarding the error, your Gmail account might have a quota per minute set to 0. Please try to increase it. Here are some resources about how to do it: https://stackoverflow.com/questions/66785834/quota-exceeded-for-quota-metric-requests-and-limit-requests-per-minute-of-se

Please check what its Request per minute in Quotas in your project Admin in Google cloud something like here: https://console.cloud.google.com/iam-admin/quotas

hieuTranEnouvo commented 1 year ago

@azadnsu Thank you for replying I can't find a quota per minute set to increase it.

Screenshot 2023-03-10 at 15 17 12

azadnsu commented 1 year ago

@hieuTranEnouvo Go to the next pages, Request per minute is there.

azadnsu commented 1 year ago

@hieuTranEnouvo You can increase quotas from there Or follow this solution posted in another thread: https://github.com/levz0r/gmail-tester/issues/78

hieuTranEnouvo commented 1 year ago

@azadnsu here what I found

Screenshot 2023-03-10 at 15 44 14

But I still don't know what the issue is

azadnsu commented 1 year ago

@hieuTranEnouvo I have no idea as well, your account got connected. Its Gmail API blocking requests which you need to figure out!

hieuTranEnouvo commented 1 year ago

OK thank @azadnsu

azadnsu commented 1 year ago

@hieuTranEnouvo Could you please try with a fresh Gmail account from the scratch. Just to give a try!

hieuTranEnouvo commented 1 year ago

@azadnsu let me check now

hieuTranEnouvo commented 1 year ago

Screenshot 2023-03-13 at 15 10 36 @azadnsu I used another account but still get the issue

azadnsu commented 1 year ago

I am sure you need to do this: https://developers.google.com/gmail/api/guides/handle-errors#:~:text=An%20error%20403%20occurs%20when,The%20daily%20limit%20was%20exceeded. @hieuTranEnouvo

hieuTranEnouvo commented 1 year ago

View or change usage limits, increase quota To view or change usage limits for your project, or to request an increase to your quota, do the following:

1/If you don't already have a billing account for your project, then create one. 2/Visit the Enabled APIs page of the API library in the API Console, and select an API from the list. 3/To view and change quota-related settings, select Quotas. To view usage statistics, select Usage.

==> I don't know how to "To view usage statistics, select Usage" pls help me that @azadnsu

azadnsu commented 1 year ago

There should be no quota problem in a normal gmail account. Looks like somehow your account is connected to business account!

hieuTranEnouvo commented 1 year ago

@azadnsu I have 3 accounts which are connected to business account? It is same the error for 3 accs

dev101 commented 1 year ago

If your mailbox contains 1000s of emails, I guess you just need to limit the result set by using some filtering options like after.

owenbendavies commented 1 year ago

Did anyone solve or update this for the OOB deprecation?

Error 400: invalid_request
The out-of-band (OOB) flow has been blocked in order to keep users secure. Follow the Out-of-Band (OOB) flow migration guide linked in the developer docs below to migrate your app to an alternative method.
Request details: redirect_uri=urn:ietf:wg:oauth:2.0:oob

Our cypress tests just started failing, and I suspect it is due the the token expiring and we can't generate a new one due to this being deprecated by google

https://developers.google.com/identity/protocols/oauth2/resources/oob-migration

neoanantha commented 8 months ago

Solution @ https://github.com/levz0r/gmail-tester/issues/126