Closed rahul-proximity closed 1 month ago
It is basic debugging, try printing emails
on line 4. Try replacing the search arguement with search("in:inbox")
to widen the search and see if it's really the program causing the problem.
@chinmayajha This did not work out. Used the email client directly. Here's what I did for your reference.
import os
import time
from google.auth.transport.requests import Request
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
SCOPES = ["https://www.googleapis.com/auth/gmail.readonly"]
class Nodes():
def __init__(self):
self.creds = self.authenticate()
self.service = build("gmail", "v1", credentials=self.creds)
def authenticate(self):
creds = None
if os.path.exists("token.json"):
creds = Credentials.from_authorized_user_file("token.json", SCOPES)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file("credentials.json", SCOPES)
creds = flow.run_local_server(port=0)
with open("token.json", "w") as token:
token.write(creds.to_json())
return creds
Changed the check_email
then to use the same.
Hi @rahul-proximity , could you provide more detail how to fix it? I cannot run this example too
Hey, I tried running this example. It doesn't seem to work. No emails are fetched despite setting up the gmail client correctly.
Even the sample code from the Gmail client works fine:
https://developers.google.com/gmail/api/quickstart/python#configure_the_sample
the seach here comes out to be an empty list every time:
@joaomdmoura