Context:
My gmail account is not a service account. I am writing a PHP CLI application which checks for an email from a specific sender and specific subject. Assume this application is for a custom domain but not part of GSuite. I do not have server-wide control over our domain's emails.
I am using my own credentials.json file for Auth from Google APIs portal. I modified the code from the Quickstart to fetch emails based on my query and get the specific email I need. (The user is 'me' by the way from Quickstart example).
Reference: PHP documentation for Gmail API
Question:
How can I make this application work for any user within my domain? Is there any possible way, I can do this without requiring another account with server-wide delegation(I hope the term is correct) access?
For example
$tmp = new CustomClassUsingGmailAPI();
$emailIds = ["email1@customdomain", "email2@customdomain"];
foreach($emailIds as $emailId){
$tmp->doTheRequiredTask($emailId);
}