Getting error:
Error (400) Precondition check failed. google/apiclient: ^1.1
I see some articles where $client->setSubject("[email protected]"); is necessary but this package has not this method.
// Set up Google API client
$client = new Google_Client();
// Load service account JSON file and set up credentials
$credentials = $client->loadServiceAccountJson(config('const.GOOGLE_APPLICATION_CREDENTIALS'), array('https://www.googleapis.com/auth/gmail.readonly'));
$client->setAssertionCredentials($credentials);
// Check if the access token is expired and refresh it if necessary
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion();
}
// Initialize Gmail Service
$gmailService = new Google_Service_Gmail($client);
// Fetch emails
$messages = $gmailService->users_messages->listUsersMessages('me', ['q' => 'has:attachment']);
dd("done", $messages); // Output the result for debugging purposes
I want to resolve my problem