I have this code
<?php
require __DIR__ . '/vendor/autoload.php';
use GoogleClient;
use GoogleServiceGmail;
try {
$client = new Google_Client();
$client->setApplicationName('gmail_list');
$client->setScopes(Google_Service_Gmail::GMAIL_READONLY);
$client->setAuthConfig('mailer-422207-065dbb2195ea.json');
// Path to your OAuth 2.0 credentials file
// Authenticate with OAuth 2.0
$client->fetchAccessTokenWithAssertion();
$accessToken = $client->getAccessToken()['access_token'];
$service = new Google_Service_Gmail($client);
$userId = 'me';
// echo "<pre>";print_r($service->users_messages);die();
$messages = $service->users_messages->listUsersMessages($userId, ['q' => 'in:inbox']);
// Proceed with other operations...
} catch (Exception $e) {
// Log or handle the error
echo 'Error: ' . $e->getMessage();
}
?>
This code gives me error
Error: { “error”: { “code”: 400, “message”: “Precondition check failed.”, “errors”: [ { “message”: “Precondition check failed.”, “domain”: “global”, “reason”: “failedPrecondition” } ], “status”: “FAILED_PRECONDITION” } }
any one can help me that where i make mistake
Error: { “error”: { “code”: 400, “message”: “Precondition check failed.”, “errors”: [ { “message”: “Precondition check failed.”, “domain”: “global”, “reason”: “failedPrecondition” } ], “status”: “FAILED_PRECONDITION” } }
govinda Delris is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.