Closed najathi closed 1 year ago
Is anyone here to answer for me?
Hi @najathi Sorry for the delay in response.
I tried your first approach and only added one small thing, i.e. the scope, https://www.googleapis.com/auth/contacts
to the google client.
With that I was able to see the synced contact in my gmail.
Please try it with the scope added and let me know if that works or not.
Thanks.
Hi @najathi Sorry for the delay in response.
I tried your first approach and only added one small thing, i.e. the scope,
https://www.googleapis.com/auth/contacts
to the google client.With that I was able to see the synced contact in my gmail.
Please try it with the scope added and let me know if that works or not.
Thanks.
@saranshdhingra
I tried earlier below the code, can you check it out, It's not working, it shows all creating contacts but contacts are not saved on google contacts.
$client = new \Google_Client();
$client->setClientId(config('google.client_id'));
$client->setClientSecret(config('google.client_secret'));
$client->setRedirectUri(config('google.redirect_uri'));
$client->setApplicationName(config('google.application_name'));
$client->setAccessType(config('google.access_type'));
$client->setScopes(config('google.scopes'));
$client->setApprovalPrompt(config('google.approval_prompt'));
$client->setPrompt(config('google.prompt'));
$client->setDeveloperKey(config('google.developer_key'));
$client->setAuthConfig(config('google.service.file'));
$service = new \Google_Service_PeopleService($client);
$newPerson = new \Google_Service_PeopleService_Person();
// Set the name of the new contact
$name = new \Google_Service_PeopleService_Name();
$name->setGivenName('John');
$name->setFamilyName('Doe');
$newPerson->setNames([$name]);
// Set the email address of the new contact
$email = new \Google_Service_PeopleService_EmailAddress();
$email->setValue('john.doe@example.com');
$newPerson->setEmailAddresses([$email]);
$createdPerson = $service->people->createContact($newPerson);
dd($createdPerson);
scopes are coming from google.php of config
'scopes' => [\Google\Service\Sheets::DRIVE, \Google\Service\Sheets::SPREADSHEETS, \Google\Service\PeopleService::CONTACTS, \Google\Service\PeopleService::CONTACTS_READONLY, \Google\Service\PeopleService::CONTACTS_OTHER_READONLY, \Google\Service\PeopleService::USERINFO_PROFILE],
If want to check the google config file. https://gist.github.com/najathi/f9c6ef76edb3aa86c0cc3cabda9e028c
So, I tried the exact same code with the only exception of the initial authorization code and I am able to see the new contacts in Google Contacts.
$client = new \Google_Client();
$client->setAuthConfig(''); // web credentials file
$client->setRedirectUri('');
$client->setScopes([\Google\Service\Sheets::DRIVE, \Google\Service\Sheets::SPREADSHEETS, \Google\Service\PeopleService::CONTACTS, \Google\Service\PeopleService::CONTACTS_READONLY, \Google\Service\PeopleService::CONTACTS_OTHER_READONLY, \Google\Service\PeopleService::USERINFO_PROFILE]);
Just to get it off our list, could you try the same with a different authorization technique?
Hi @najathi Were you able to test the approach with a different auth technique?
Closing this for now. But, please feel to reopen this if this issue pops up again.
I am using the Google People API to create a new contact in Google Contacts but it is not saved or synced in Google Contacts. I'm not getting any errors.
Here is the code I am using to create the contact:
The $newContact variable contains the newly created contact's resource name. I have also tried requesting a sync for the connection, as follows:
However, the contact is still not saved or synced in Google Contacts.
Can anyone please advise on what might be causing this issue, and how I can get the newly created contact to be saved and synced in Google Contacts? Thank you in advance for your help.